View on GitHub

oop

Αντικειμενοστραφής Προγραμματισμός (C++)

Λύση 3ης εργασίας

Κώδικας

Μεταγλώττιση και εκτέλεση κώδικα (Windows)

$ make -f makefile_win.mk
g++ -c model.cpp -o model.o -Wall -O2 -std=c++11
g++ -c util.cpp -o util.o -Wall -O2 -std=c++11
g++ -c main.cpp -o main.o -Wall -O2 -std=c++11
g++ -c db.cpp -o db.o -Wall -O2 -std=c++11
gcc -c sqlite3.c -o sqlite3.o -lpthread
g++ model.o util.o main.o db.o sqlite3.o -o main -Wall -O2 -std=c++11
g++ -c tests_main.cpp -o tests_main.o -Wall -O2 -std=c++11
g++ model.o util.o tests_main.o tests.cpp -o tests -Wall -O2 -std=c++11
$ main.exe
WINDOWS
TIMETABLE IS NOT LOADED
1. Load data from text file
2. Check validity of timetable
3. Print timetable by day
4. Print timetable by course
5. Print timetable by lecturer
6. Write data to SQLiteDB
7. Read data from SQLiteDB
8. Exit
Enter choice:
...
$ tests.exe
CHECK 1: CONSISTENT COURSE HOURS AND TEACHING HOURS
CHECK 2: NO CLASSROOM OVERLAPS
CHECK 3: NO LECTURER OVELAPS
===============================================================================
All tests passed (19 assertions in 3 test cases)
$ make -f makefile_win.mk clean
del main.exe tests.exe *.o

Μεταγλώττιση και εκτέλεση κώδικα (Linux)

$ make -f makefile_linux.mk
g++ -c model.cpp -o model.o -Wall -O2 -pthread -ldl -std=c++11
g++ -c util.cpp -o util.o -Wall -O2 -pthread -ldl -std=c++11
g++ -c main.cpp -o main.o -Wall -O2 -pthread -ldl -std=c++11
g++ -c db.cpp -o db.o -Wall -O2 -pthread -ldl -std=c++11
gcc -c sqlite3.c -o sqlite3.o -lpthread
g++ model.o util.o main.o db.o sqlite3.o -o main -Wall -O2 -pthread -ldl -std=c++11
g++ -c tests_main.cpp -o tests_main.o -Wall -O2 -pthread -ldl -std=c++11
g++ model.o util.o tests_main.o tests.cpp -o tests -Wall -O2 -pthread -ldl -std=c++11
$ ./main
LINUX
TIMETABLE IS NOT LOADED
1. Load data from text file
2. Check validity of timetable
3. Print timetable by day
4. Print timetable by course
5. Print timetable by lecturer
6. Write data to SQLiteDB
7. Read data from SQLiteDB
8. Exit
Enter choice:
...
$ ./tests
CHECK 1: CONSISTENT COURSE HOURS AND TEACHING HOURS
CHECK 2: NO CLASSROOM OVERLAPS
CHECK 3: NO LECTURER OVELAPS
===============================================================================
All tests passed (19 assertions in 3 test cases)
$ make -f makefile_linux.mk clean
rm main tests *.o

Μεταγλώττιση και εκτέλεση κώδικα (OSX)

$ make -f makefile_osx.mk
clang++ -c model.cpp -o model.o -Wall -O2 -pedantic -std=c++11
clang++ -c util.cpp -o util.o -Wall -O2 -pedantic -std=c++11
clang++ -c main.cpp -o main.o -Wall -O2 -pedantic -std=c++11
clang++ -c db.cpp -o db.o -Wall -O2 -pedantic -std=c++11
clang++ model.o util.o main.o db.o sqlite3.o -o main -Wall -O2 -pedantic -std=c++11
clang++ model.o util.o tests_main.o tests.cpp -o tests -Wall -O2 -pedantic -std=c++11
$ ./main
MACOS
TIMETABLE IS NOT LOADED
1. Load data from text file
2. Check validity of timetable
3. Print timetable by day
4. Print timetable by course
5. Print timetable by lecturer
6. Write data to SQLiteDB
7. Read data from SQLiteDB
8. Exit
Enter choice:
...
$ ./tests
CHECK 1: CONSISTENT COURSE HOURS AND TEACHING HOURS
CHECK 2: NO CLASSROOM OVERLAPS
CHECK 3: NO LECTURER OVELAPS
===============================================================================
All tests passed (19 assertions in 3 test cases)
$ make -f makefile_osx.mk clean
rm main tests *.o