├── .replit ├── code ├── coverage │ ├── fact.h │ ├── misc.h │ ├── main.cpp │ ├── misc.cpp │ ├── tests.cpp │ ├── fact.cpp │ ├── README.org │ └── Makefile ├── testing │ ├── doctest │ │ ├── real-world-example │ │ │ ├── .#Makefile │ │ │ ├── fact.h │ │ │ ├── tests.cpp │ │ │ ├── fact.cpp │ │ │ ├── main.cpp │ │ │ ├── fact-tests.cpp │ │ │ └── Makefile │ │ ├── model-for-class-labs │ │ │ ├── fact.h │ │ │ ├── main.cpp │ │ │ ├── fact.cpp │ │ │ ├── Makefile │ │ │ └── tests.cpp │ │ └── simple │ │ │ └── fact.cpp │ ├── two_makes │ │ ├── piglatinify.h │ │ ├── main.cpp │ │ ├── piglatinify.cpp │ │ ├── Makefile │ │ └── tests.cpp │ └── plain │ │ └── log.cpp ├── make │ ├── advanced │ │ ├── morefuncs.h │ │ ├── morefuncs.cpp │ │ ├── funcs.cpp │ │ ├── funcs.h │ │ ├── main.cpp │ │ └── Makefile │ ├── multi-files │ │ ├── morefuncs.h │ │ ├── morefuncs.cpp │ │ ├── funcs.cpp │ │ ├── funcs.h │ │ ├── Makefile │ │ └── main.cpp │ └── simple │ │ ├── main.cpp │ │ └── Makefile ├── debug │ ├── Makefile │ ├── timer.cpp │ ├── Makefile-logger │ ├── gdb-demo1.cpp │ └── main.cpp ├── multi-files │ ├── funcs.cpp │ ├── funcs.h │ └── main.cpp ├── valid-exceptions │ └── valid.cpp ├── functional │ └── racket-demo.rkt ├── managed_pointers │ ├── manual.cpp │ └── managed.cpp └── shapes │ └── shapes.cpp ├── .gitignore └── README.org /.replit: -------------------------------------------------------------------------------- 1 | language = "bash" 2 | run = "" -------------------------------------------------------------------------------- /code/coverage/fact.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int fact(int n); 4 | -------------------------------------------------------------------------------- /code/coverage/misc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | int sum(int, int); 3 | int sumsq(int x); 4 | -------------------------------------------------------------------------------- /code/testing/doctest/real-world-example/.#Makefile: -------------------------------------------------------------------------------- 1 | zamansky@gatherer.896097:1670506137 -------------------------------------------------------------------------------- /code/testing/doctest/model-for-class-labs/fact.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int fact(int n); 4 | -------------------------------------------------------------------------------- /code/testing/doctest/real-world-example/fact.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int fact(int n); 4 | -------------------------------------------------------------------------------- /code/make/advanced/morefuncs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int add4(int a, int b, int c, int d); 4 | -------------------------------------------------------------------------------- /code/make/multi-files/morefuncs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int add4(int a, int b, int c, int d); 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | a.out 2 | main 3 | tests 4 | *.o 5 | *~ 6 | \#* 7 | *gcov 8 | *gcda 9 | *gcno 10 | -------------------------------------------------------------------------------- /code/make/simple/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | std::cout << "Hello World!\n"; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /code/testing/two_makes/piglatinify.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "piglatinify.h" 3 | 4 | std::string piglatinify(std::string word); 5 | -------------------------------------------------------------------------------- /code/testing/doctest/real-world-example/tests.cpp: -------------------------------------------------------------------------------- 1 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 2 | 3 | #include "fact.h" 4 | #include "doctest.h" 5 | 6 | -------------------------------------------------------------------------------- /code/testing/two_makes/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "piglatinify.h" 3 | 4 | int main() 5 | { 6 | std:: cout << "Hello wold!"; 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /code/testing/two_makes/piglatinify.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "piglatinify.h" 3 | 4 | std::string piglatinify(std::string word){ 5 | return word; 6 | } 7 | -------------------------------------------------------------------------------- /code/make/advanced/morefuncs.cpp: -------------------------------------------------------------------------------- 1 | #include "funcs.h" 2 | #include "morefuncs.h" 3 | 4 | int add4(int a, int b, int c, int d) 5 | { 6 | return add3(a, b, c) + d; 7 | } 8 | -------------------------------------------------------------------------------- /code/make/multi-files/morefuncs.cpp: -------------------------------------------------------------------------------- 1 | #include "funcs.h" 2 | #include "morefuncs.h" 3 | 4 | int add4(int a, int b, int c, int d) 5 | { 6 | return add3(a, b, c) + d; 7 | } 8 | -------------------------------------------------------------------------------- /code/debug/Makefile: -------------------------------------------------------------------------------- 1 | main: main.o 2 | g++ -o main main.o 3 | 4 | main.o: main.cpp 5 | g++ -c $(CXXFLAGS) main.cpp 6 | 7 | clean: 8 | rm -f main.o 9 | 10 | debug: CXXFLAGS := $(CXXFLAGS) -g 11 | debug: main 12 | -------------------------------------------------------------------------------- /code/multi-files/funcs.cpp: -------------------------------------------------------------------------------- 1 | #include "funcs.h" 2 | 3 | 4 | int add3(int a, int b, int c) { 5 | return c+add2(a,b); 6 | } 7 | 8 | int add2(int a, int b) { 9 | int c; 10 | c = a + b; 11 | return c; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /code/make/advanced/funcs.cpp: -------------------------------------------------------------------------------- 1 | #include "funcs.h" 2 | 3 | 4 | int add3(int a, int b, int c) { 5 | return c+add2(a,b); 6 | } 7 | 8 | int add2(int a, int b) { 9 | int c; 10 | c = a + b; 11 | return c; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /code/make/multi-files/funcs.cpp: -------------------------------------------------------------------------------- 1 | #include "funcs.h" 2 | 3 | 4 | int add3(int a, int b, int c) { 5 | return c+add2(a,b); 6 | } 7 | 8 | int add2(int a, int b) { 9 | int c; 10 | c = a + b; 11 | return c; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /code/testing/doctest/real-world-example/fact.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "fact.h" 4 | int fact(int n){ 5 | if (n <= 1){ 6 | return 1; 7 | } else { 8 | return n * fact(n-1); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /code/debug/timer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | int main() 6 | { 7 | int i; 8 | while(true){ 9 | sleep(1); 10 | i++; 11 | std::cout << i << "\n"; 12 | } 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /code/make/advanced/funcs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* IMPORTANT 4 | 5 | .h (include) files should ONLY contain 6 | prototypes and definitions, not runnable code 7 | */ 8 | 9 | int add2(int, int); 10 | int add3(int, int, int); 11 | 12 | -------------------------------------------------------------------------------- /code/make/simple/Makefile: -------------------------------------------------------------------------------- 1 | main: main.o 2 | g++ -o main main.o 3 | 4 | main.o: main.cpp 5 | g++ -c main.cpp 6 | 7 | clean: 8 | rm -f main.o 9 | help: 10 | @echo "Targets: main" 11 | @echo " clean" 12 | @echo " help" 13 | -------------------------------------------------------------------------------- /code/multi-files/funcs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* IMPORTANT 4 | 5 | .h (include) files should ONLY contain 6 | prototypes and definitions, not runnable code 7 | */ 8 | 9 | int add2(int, int); 10 | int add3(int, int, int); 11 | 12 | -------------------------------------------------------------------------------- /code/make/multi-files/funcs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* IMPORTANT 4 | 5 | .h (include) files should ONLY contain 6 | prototypes and definitions, not runnable code 7 | */ 8 | 9 | int add2(int, int); 10 | int add3(int, int, int); 11 | 12 | -------------------------------------------------------------------------------- /code/debug/Makefile-logger: -------------------------------------------------------------------------------- 1 | logger: logger.o 2 | g++ -o logger logger.o 3 | 4 | logger.o: logger.cpp 5 | g++ -c $(CXXFLAGS) logger.cpp 6 | 7 | clean: 8 | rm -f logger.o 9 | 10 | debug: CXXFLAGS := $(CXXFLAGS) -DDEBUG=1 -g 11 | debug: logger 12 | -------------------------------------------------------------------------------- /code/testing/doctest/real-world-example/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "fact.h" 4 | 5 | int main() 6 | { 7 | std::cout << "In main\n"; 8 | int n = fact(5); 9 | std::cout << "5 fact is " << n << "\n"; 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /code/coverage/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "fact.h" 3 | 4 | int main() 5 | { 6 | std::cout <<"In the main\n"; 7 | int result = fact(1); 8 | std::cout << result << "\n"; 9 | result = fact(5); 10 | std::cout << result << "\n"; 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /code/testing/doctest/model-for-class-labs/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "fact.h" 3 | 4 | int main() 5 | { 6 | std::cout <<"In the main\n"; 7 | int result = fact(1); 8 | std::cout << result << "\n"; 9 | result = fact(5); 10 | std::cout << result << "\n"; 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /code/multi-files/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "funcs.h" 4 | 5 | 6 | int main() 7 | { 8 | std::cout << "Hello world!\n"; 9 | int x = add2(5,8); 10 | 11 | std::cout << "5 + 8 = " << x << "\n"; 12 | int y = add3(5,8,3); 13 | std::cout << "5 + 8 + 3 = " << y << "\n"; 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /code/testing/doctest/model-for-class-labs/fact.cpp: -------------------------------------------------------------------------------- 1 | #include "fact.h" 2 | 3 | 4 | int fact(int n) { 5 | if (n < 2){ 6 | return 1; 7 | } else { 8 | int result = 2; 9 | for (int i = n; n > 2; n = n - 1){ 10 | result = result * n; 11 | } 12 | return result; 13 | 14 | } 15 | } 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /code/coverage/misc.cpp: -------------------------------------------------------------------------------- 1 | 2 | int sum(int a, int b) { 3 | int result=0; 4 | for (int i = a ; i <= b; i++){ 5 | result = result + i; 6 | } 7 | return result; 8 | 9 | } 10 | 11 | int sumsq(int x) { 12 | int result = 0; 13 | for (int i = 0 ; i < x; i++){ 14 | result = result + i*i; 15 | } 16 | return result; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /code/coverage/tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 3 | #include "fact.h" 4 | #include "misc.h" 5 | #include "doctest.h" 6 | 7 | TEST_CASE("Factorial Tests") { 8 | CHECK(fact(1)==1); 9 | CHECK(fact(5)==20); 10 | CHECK(fact(101)==99999); 11 | } 12 | 13 | TEST_CASE("Misc tests") { 14 | CHECK(sum(0,3)==6); 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /code/make/multi-files/Makefile: -------------------------------------------------------------------------------- 1 | main: main.o funcs.o morefuncs.o 2 | g++ -o main main.o funcs.o morefuncs.o 3 | main.o: main.cpp funcs.h morefuncs.h 4 | g++ -c main.cpp 5 | funcs.o: funcs.cpp funcs.h 6 | g++ -c funcs.cpp 7 | morefuncs.o: morefuncs.cpp morefuncs.h funcs.h 8 | g++ -c morefuncs.cpp 9 | 10 | clean: 11 | rm -f main.o funcs.o morefuncs.o 12 | -------------------------------------------------------------------------------- /code/coverage/fact.cpp: -------------------------------------------------------------------------------- 1 | #include "fact.h" 2 | 3 | 4 | int fact(int n) { 5 | if (n < 2){ 6 | return 1; 7 | } else if (n > 100 && n < 150){ 8 | return 99999; 9 | } else { 10 | int result = 2; 11 | for (int i = n; n > 2; n = n - 1){ 12 | result = result * n; 13 | } 14 | return result; 15 | 16 | } 17 | } 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /code/testing/two_makes/Makefile: -------------------------------------------------------------------------------- 1 | 2 | main: main.o piglatinify.o 3 | g++ -o main main.o piglatinify.o 4 | 5 | tests: tests.o piglatinify.o 6 | g++ -o tests tests.o piglatinify.o 7 | 8 | tests.o: tests.cpp piglatinify.h 9 | 10 | main.o: main.cpp piglatinify.h 11 | 12 | piglatinify.o: piglatinify.cpp piglatinify.h 13 | 14 | clean: 15 | rm -f main.o piglatinify.o tests.o 16 | -------------------------------------------------------------------------------- /code/coverage/README.org: -------------------------------------------------------------------------------- 1 | * Info on coverage tools 2 | ** Tools 3 | - gcov - probably built in 4 | - sudo apt-get install lcov gcovr 5 | 6 | ** To run 7 | add --coverage -g -O0 flags to compile lines 8 | gcov *cpp to generate coverage reports 9 | lcov -capture -directory . --output-file z.info 10 | genhtml z.info --output-directory od 11 | gcovr -r . --html --html-details -o cov.html 12 | -------------------------------------------------------------------------------- /code/testing/doctest/model-for-class-labs/Makefile: -------------------------------------------------------------------------------- 1 | OBJECTS=fact.o 2 | 3 | main: main.o $(OBJECTS) 4 | g++ -o main main.o $(OBJECTS) 5 | 6 | tests: tests.o $(OBJECTS) 7 | g++ -o tests tests.o $(OBJECTS) 8 | 9 | fact.o: fact.cpp fact.h 10 | 11 | main.o: main.cpp fact.h 12 | 13 | tests.o: tests.cpp fact.h 14 | 15 | 16 | clean: 17 | rm -f $(OBJECTS) main.o tests.o 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /code/testing/plain/log.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | #ifdef USELOG 5 | #define LOG(x) std::cerr << x << "\n"; 6 | #else 7 | #define LOG(x) 8 | #endif 9 | 10 | int main() 11 | { 12 | 13 | std::cout << "cout 1\n"; 14 | std::cerr << "cerr 1\n"; 15 | std::cout << "cout 2\n"; 16 | std::cerr << "cerr 2\n"; 17 | std::cout << "cout 3\n"; 18 | 19 | LOG("HELLO WORLD"); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /code/make/advanced/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "funcs.h" 4 | #include "morefuncs.h" 5 | 6 | int main() 7 | { 8 | std::cout << "Hello world!\n"; 9 | int x = add2(5,8); 10 | 11 | std::cout << "5 + 8 = " << x << "\n"; 12 | int y = add3(5,8,3); 13 | std::cout << "5 + 8 + 3 = " << y << "\n"; 14 | int z = add4(5,8,3,7); 15 | std::cout << "5 + 8 + 3 + 7 = " << z << "\n"; 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /code/make/multi-files/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "funcs.h" 4 | #include "morefuncs.h" 5 | 6 | int main() 7 | { 8 | std::cout << "Hello world!\n"; 9 | int x = add2(5,8); 10 | 11 | std::cout << "5 + 8 = " << x << "\n"; 12 | int y = add3(5,8,3); 13 | std::cout << "5 + 8 + 3 = " << y << "\n"; 14 | int z = add4(5,8,3,7); 15 | std::cout << "5 + 8 + 3 + 7 = " << z << "\n"; 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /code/coverage/Makefile: -------------------------------------------------------------------------------- 1 | OBJECTS=fact.o misc.o 2 | CXXFLAGS=--coverage -g -O0 3 | 4 | main: main.o $(OBJECTS) 5 | g++ -o main main.o $(OBJECTS) 6 | 7 | tests: tests.o $(OBJECTS) 8 | g++ -o tests $(CXXFLAGS) tests.o $(OBJECTS) 9 | 10 | fact.o: fact.cpp fact.h 11 | 12 | misc.o: misc.cpp misc.h 13 | 14 | main.o: main.cpp fact.h 15 | 16 | tests.o: tests.cpp fact.h misc.h 17 | 18 | 19 | clean: 20 | rm -f $(OBJECTS) main.o tests.o 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /code/testing/doctest/model-for-class-labs/tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 3 | #include "fact.h" 4 | #include "doctest.h" 5 | 6 | TEST_CASE("Factorial Base Cases") { 7 | CHECK(fact(0) == 1); 8 | CHECK(fact(1) == 1); 9 | } 10 | 11 | 12 | TEST_CASE("Factorial Small numbers") { 13 | CHECK(fact(2) == 2); 14 | CHECK(fact(3) == 6); 15 | CHECK(fact(4) == 24); 16 | } 17 | 18 | TEST_CASE("Factorial large numbers") { CHECK(fact(5) == 120); } 19 | -------------------------------------------------------------------------------- /code/debug/gdb-demo1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int prod(int max){ 3 | int prod = 1; 4 | int i; 5 | for (i=1;i 2 | 3 | int main() 4 | { 5 | std::string s; 6 | double d; 7 | bool try_again = true; 8 | std::cout << "Enter a number:"; 9 | while (try_again){ 10 | std::getline(std::cin,s); 11 | try { 12 | d = std::stold(s); 13 | try_again = false; 14 | } catch (std::exception e){ 15 | std::cout << "Try again, enter a number:"; 16 | try_again = true; 17 | } 18 | } 19 | 20 | std::cout << "You entered: " << d << "\n"; 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /code/testing/doctest/real-world-example/Makefile: -------------------------------------------------------------------------------- 1 | OBJECTS=main.o fact.o tests.o fact-tests.o 2 | 3 | main: main.o fact.o 4 | g++ -o main main.o fact.o 5 | 6 | tests: tests.o fact.o fact-tests.o 7 | g++ -o tests tests.o fact.o fact-tests.o 8 | 9 | test.o: tests.cpp fact.h 10 | g++ -c tests.cpp 11 | 12 | fact-tests.o: fact-tests.cpp fact.h 13 | g++ -c fact-tests.cpp 14 | 15 | main.o: main.cpp fact.h 16 | g++ -c main.cpp 17 | 18 | fact.o: fact.cpp fact.h 19 | g++ -c fact.cpp 20 | 21 | clean: 22 | rm -f $(OBJECTS) 23 | 24 | 25 | -------------------------------------------------------------------------------- /code/testing/doctest/simple/fact.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 3 | #include "doctest.h" 4 | int fact(int n) { 5 | return 1; 6 | 7 | } 8 | 9 | TEST_CASE("Factorial Base Cases") { 10 | CHECK(fact(0) == 1); 11 | CHECK(fact(1) == 1); 12 | } 13 | 14 | 15 | TEST_CASE("Factorial Small numbers") { 16 | CHECK(fact(2) == 2); 17 | CHECK(fact(3) == 6); 18 | CHECK(fact(4) == 24); 19 | } 20 | 21 | TEST_CASE("Factorial large numbers") { 22 | CHECK(fact(5) == 120); 23 | 24 | } 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /code/make/advanced/Makefile: -------------------------------------------------------------------------------- 1 | OBJECTS=main.o funcs.o morefuncs.o 2 | CXX=g++ 3 | CXXFLAGS= 4 | LDFLAGS= 5 | 6 | main: main.o funcs.o morefuncs.o 7 | g++ $(LDFLAGS) -o main $(OBJECTS) 8 | 9 | main.o: main.cpp funcs.h morefuncs.h 10 | g++ $(CXXFLAGS) -c main.cpp 11 | 12 | funcs.o: funcs.cpp funcs.h 13 | g++ $(CXXFLAGS) -c funcs.cpp 14 | 15 | morefuncs.o: morefuncs.cpp morefuncs.h funcs.h 16 | g++ $(CXXFLAGS) -c morefuncs.cpp 17 | 18 | clean: 19 | rm -f $(OBJECTS) 20 | 21 | help: 22 | @echo "Targets:" 23 | @echo " main" 24 | @echo " clean" 25 | @echo " help" 26 | -------------------------------------------------------------------------------- /code/functional/racket-demo.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (define sq (lambda (x) (* x x))) 4 | 5 | (define l '(1 2 3 4 5)) 6 | 7 | (map sq l) 8 | 9 | (define make-adder (lambda (x) 10 | (lambda (y) (+ x y)))) 11 | 12 | (define add3 (make-adder 3)) 13 | (add3 20) 14 | 15 | (define make-counter 16 | (lambda () 17 | (let ([x 0]) 18 | (lambda (op) 19 | (cond [ (equal? op +) (set! x (+ x 1))] 20 | [ (equal? op -) (set! x (- x 1))] 21 | [ (equal? op =) x] 22 | [ (equal? op 'reset) (set! x 0)] 23 | ) 24 | x)))) 25 | 26 | (define c (make-counter)) 27 | -------------------------------------------------------------------------------- /code/testing/two_makes/tests.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "piglatinify.h" 3 | 4 | 5 | int main() 6 | { 7 | // Test for empty string 8 | std::string result; 9 | 10 | std::cout << "Testing empty string\n"; 11 | result = piglatinify(""); 12 | if (result==""){ 13 | std::cout << "Success\n\n"; 14 | } else { 15 | std::cout << "Failure\n\n"; 16 | } 17 | 18 | std::cout << "Testing single letter\n"; 19 | if (piglatinify("a") == "a" && 20 | piglatinify("b") == "b"){ 21 | std::cout << "Success\n\n"; 22 | } else { 23 | std::cout << "Failure\n\n"; 24 | } 25 | 26 | std::cout << "Testing single vowel words\n"; 27 | if (piglatinify("able") == "ableyay"){ 28 | 29 | std::cout << "Success\n\n"; 30 | } else { 31 | std::cout << "Failure\n\n"; 32 | } 33 | 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /code/managed_pointers/manual.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | class pt{ 5 | private: 6 | int x,y; 7 | public: 8 | pt() { 9 | this->x = 0; 10 | this->y = 0; 11 | } 12 | pt(int x, int y){ 13 | this->x = x; 14 | this->y = y; 15 | } 16 | ~pt() { 17 | std::cout << "In the destructor for " << this->toString() << "\n"; 18 | } 19 | std::string toString(){ 20 | return "<" + std::to_string(x) + "," + std::to_string(y) + ">"; 21 | } 22 | 23 | }; 24 | 25 | void f(){ 26 | pt mypoint(10,20); 27 | 28 | pt *p = new pt(1,2); 29 | 30 | std::cout << mypoint.toString() << "\n"; 31 | std::cout << p->toString() << "\n"; 32 | 33 | std::cout << "About to return from f\n"; 34 | delete p; 35 | } 36 | 37 | 38 | int main(){ 39 | f(); 40 | std::cout << "returned from f\n"; 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /code/managed_pointers/managed.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | class pt{ 6 | private: 7 | int x,y; 8 | public: 9 | pt() { 10 | this->x = 0; 11 | this->y = 0; 12 | } 13 | pt(int x, int y){ 14 | this->x = x; 15 | this->y = y; 16 | } 17 | ~pt() { 18 | std::cout << "In the destructor for " << this->toString() << "\n"; 19 | } 20 | std::string toString(){ 21 | return "<" + std::to_string(x) + "," + std::to_string(y) + ">"; 22 | } 23 | 24 | }; 25 | 26 | void f(){ 27 | pt mypoint(10,20); 28 | 29 | //pt *p = new pt(1,2); 30 | std::shared_ptr p(new pt(100,200)); 31 | 32 | auto p2 = std::make_shared(123,456); 33 | auto p3 = std::make_shared(); 34 | 35 | std::cout << mypoint.toString() << "\n"; 36 | std::cout << p->toString() << "\n"; 37 | std::cout << p2->toString() << "\n"; 38 | std::cout << p3->toString() << "\n"; 39 | 40 | std::cout << "About to return from f\n"; 41 | // delete p; 42 | } 43 | 44 | 45 | int main(){ 46 | f(); 47 | std::cout << "returned from f\n"; 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /code/debug/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "stdlib.h" 4 | 5 | #ifdef DEBUG 6 | #define LOG(X) std::cout << X << std::endl; 7 | #else 8 | #define LOG(X) 9 | #endif 10 | 11 | int fact(int n){ 12 | if (n==0) 13 | return 1; 14 | else 15 | return n * fact(n-1); 16 | } 17 | 18 | int f3(int a){ 19 | int x; 20 | 21 | x = a; 22 | 23 | if( x> 700832 && x < 8000000) 24 | abort(); 25 | return a+20; 26 | 27 | } 28 | 29 | int f2(int a){ 30 | int z; 31 | z = a; 32 | if (z%2==0) 33 | return f2(z+1); 34 | else 35 | return f3(z); 36 | 37 | } 38 | 39 | int f(int a){ 40 | int x; 41 | x = x + f2(x); 42 | return x; 43 | 44 | } 45 | 46 | struct mystruct { 47 | int a; 48 | double d; 49 | int stuff[10]; 50 | }; 51 | 52 | int main(int argc, char *argv[]) 53 | { 54 | LOG("HELLO"); 55 | int a,i,b; 56 | struct mystruct s1; 57 | struct mystruct *ps; 58 | 59 | ps = &s1; 60 | 61 | s1.a=100; 62 | s1.d=20.3; 63 | s1.stuff[3]=100; 64 | s1.stuff[5]=20; 65 | 66 | a = 20; 67 | int ar[10]; 68 | 69 | 70 | for (i = 0; i < 10; ++i) { 71 | ar[i] = i*10; 72 | } 73 | 74 | 75 | 76 | for (i = 0; i < 15; ++i) { 77 | a = a + f(i); 78 | a = a * a; 79 | a = a - 5; 80 | b = a + i; 81 | } 82 | std::cout << fact(5) << "\n"; 83 | 84 | } 85 | -------------------------------------------------------------------------------- /code/shapes/shapes.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | std::string line(int len, char c){ 4 | std::string result = ""; 5 | for (int i = 0; i < len; i++){ 6 | result = result + c; 7 | } 8 | return result; 9 | } 10 | 11 | std::string box(int h, int w) { 12 | std::string result=""; 13 | int row,col; 14 | for (row = 0; row < h; row++){ 15 | result = result + line(w,'*')+"\n"; 16 | } 17 | 18 | return result; 19 | } 20 | 21 | std::string ltriangle(int l) { 22 | std::string result = ""; 23 | int row,col; 24 | for ( row = 0 ; row < l; row++){ 25 | result = result + line(row+1,'*') + "\n"; 26 | } 27 | return result; 28 | } 29 | 30 | std::string utriangle(int l) { 31 | std::string result = ""; 32 | int row,col; 33 | for ( row = 0 ; row < l; row++){ 34 | result = result + line(row,' '); 35 | result = result + line(l-row,'*'); 36 | result = result + "\n"; 37 | } 38 | return result; 39 | } 40 | 41 | std::string trap(int w, int h) { 42 | std::string result = ""; 43 | int row; 44 | for (row = 0; row < h; row++){ 45 | result = result + line(row, ' '); 46 | result = result + line(w,'*'); 47 | w = w - 2; 48 | result = result + "\n"; 49 | } 50 | 51 | return result; 52 | } 53 | 54 | 55 | int main() 56 | { 57 | std::string result; 58 | 59 | result = box(4,3); 60 | std::cout << "Box\n--------\n"; 61 | std::cout << result; 62 | std::cout << "\n--------------\n\n"; 63 | 64 | 65 | result = ltriangle(6); 66 | std::cout << "ltriangle\n--------\n"; 67 | std::cout << result; 68 | std::cout << "\n--------------\n\n"; 69 | 70 | result = utriangle(6); 71 | std::cout << "utriangle\n--------\n"; 72 | std::cout << result; 73 | std::cout << "\n--------------\n\n"; 74 | 75 | result = trap(12,5); 76 | std::cout << "trap\n--------\n"; 77 | std::cout << result; 78 | std::cout << "\n--------------\n\n"; 79 | return 0; 80 | } 81 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | * CSCI 13500 - Daedalus 2 | 3 | | Meets | Monday Thursday 10:00 - 10:50 | 4 | | Room | Hunter North C107 | 5 | | Instructor | Mike Zamansky | 6 | | Email | mz631@hunter.cuny.edu | 7 | | Office | 1001K Hunter North | 8 | | Office Hours | By appointment | 9 | 10 | 11 | * Main Syllabus Link 12 | 13 | - [[https://maryash.github.io/135/index.html][Main 135 page]] 14 | 15 | 16 | * Getting help 17 | 18 | Use Zulip for help. These streams in particular: 19 | 20 | - #135 this goes to everyone in our section 21 | - #2022 goes to all members of the current first year Daedalus cohort 22 | - #general the Daedalus members 23 | 24 | There are also tutoring sessions listed on 25 | the main 135 lecture page (see above). 26 | 27 | * Class policies and grading 28 | 29 | ** Grading 30 | 31 | - Labs will be graded on a 0 - 10 scale. 32 | - Unless otherwise noted labs will be released Mondays after class and 33 | will be due Friday of the same week at 7:00am. 34 | - Lab specifications are different for our recitation than for the 35 | other recitations. Specifics will be written in the lab 36 | assignments. 37 | - Most labs will be completed outside of class time as homework 38 | assignments however some will take place during or will replace some 39 | synchronous class time. 40 | - Our section will include additional labs and some of the labs will 41 | include additional material. 42 | - Assuming all labs are assigned and completed, the lowest grade will 43 | not be included in calculating the lab average. 44 | - If a lab cannot be completed on time, you are expected to discuss 45 | this with the instructor prior to the due date/time. Under some 46 | circumstances the instructor might accept work submitted or updated 47 | after the due date/time. Otherwise, late labs will not be accepted 48 | - Labs will be compiled, run, and tested under Linux. It is the students 49 | responsiblity to ensure that their labs work on this platform. 50 | - Labs will not be regraded. 51 | 52 | ** Differences from the non Daedalus sections 53 | 54 | - We will *not* be using Gradescope for our labs. That said, you are 55 | expected to use *Gradescope* and follow all requirements for the 56 | main lecture. So, while you will use GitHub for our labs, you will 57 | submit projects, take tests, complete homework assignments and 58 | problem sets following the main 135 instructors directions. 59 | 60 | 61 | ** Cameras during synchronous classes 62 | 63 | Students are asked to have their cameras on during synchronous classes 64 | as this makes the class feel more like a community. If a student does 65 | not wish or is unable to comply with this request they must disucss 66 | this with the instructor the instructor 67 | 68 | * Lab instructions 69 | 70 | This recitation *will not* be using Gradescope for our labs. Instead, 71 | we are using GitHub Classroom. An email will be posted on Zulip with a 72 | link when each lab is released. 73 | 74 | Students should: 75 | 76 | 1. Accept the assignment 77 | 2. Clone the repo to their local machine. 78 | 3. Complete the lab as instructed 79 | 80 | Labs will be graded on the instructors Linux computer so you should be 81 | sure that your solutions will compile and run as instructed on that 82 | platform. Also, only include source files and other files explicitly 83 | asked for in your repository. Do not add executable files (a.out, for 84 | instance) or object (.o) files to the repository. 85 | 86 | *Due Dates:* Unless otherwise noted, labs will be released on Mondays 87 | after class and will be due the Friday morning of that week at 88 | 8:00am. 89 | 90 | * Emacs links 91 | - [[https://www.masteringemacs.org/reading-guide][Mastering Emacs reading guide]] 92 | - [[http://sachachua.com/blog/2013/05/how-to-learn-emacs-a-hand-drawn-one-pager-for-beginners/][How to learn Emacs]] 93 | - [[http://cestlaz.github.io/stories/emacs][Using Emacs video series]] 94 | 95 | * Resources 96 | ** C++ 97 | - John Sterlings C++ Class Notes: http://cis.poly.edu/jsterling/cs2124/ 98 | 99 | ** Unix Command Line / Shell 100 | 1) [[https://hellowebbooks.com/learn-command-line/][Learn the Command Line]] - Mac version 101 | 2) [[https://www.codecademy.com/learn/learn-the-command-line][Learn the Command Line]] 102 | 3) [[http://linuxcommand.org/]] 103 | 4) https://hellowebbooks.com/learn-command-line/ 104 | --------------------------------------------------------------------------------