72 lines
1.9 KiB
C++
72 lines
1.9 KiB
C++
#include "ListDisplay.hpp"
|
|
#include "ListE.hpp"
|
|
#include "Record.hpp"
|
|
#include "Tools.hpp"
|
|
#include <iomanip>
|
|
#include <iostream>
|
|
|
|
template <class E> void display(List<E> list) {
|
|
for (int i = 0; i < list.length(); i++) {
|
|
std::cout << list[i] << ' ';
|
|
}
|
|
std::cout << std::endl;
|
|
}
|
|
|
|
int main() {
|
|
List<int> aList;
|
|
aList.append(4);
|
|
aList.append(5);
|
|
aList.append(6);
|
|
aList.append(7);
|
|
display(aList);
|
|
aList.append(8);
|
|
aList.pop(0);
|
|
display(aList);
|
|
|
|
aList.swap(0, 3);
|
|
display(aList);
|
|
|
|
// aList.sort([](const int &a, const int &b) { return a > b; });
|
|
|
|
// display(aList);
|
|
|
|
List<int> bList =
|
|
aList.sorted([](const int &a, const int &b) { return a > b; });
|
|
|
|
display(bList);
|
|
|
|
bList.append(5);
|
|
|
|
display(bList);
|
|
|
|
bList.filter([](const int &a) { return a > 6; });
|
|
display(bList);
|
|
std::cout << "hhh" << setoutputcolor(ConsoleColorTool::blue, true) << "aaa"
|
|
<< setoutputcolor(ConsoleColorTool::blue, false) << "bbb"
|
|
<< resetOutputColor << std::endl;
|
|
LateRecord la(125534456, "SomeCourselonglonglonglonglong", 10821398, "SomeStu");
|
|
AbsentRecord lb(2874238743, "SomeOtherCourse", 10239944, "SomeotherStu");
|
|
la.display();
|
|
std::cout << setbgcolor(ConsoleColorTool::lightGray);
|
|
lb.display();
|
|
std::cout << resetOutputColor;
|
|
|
|
// la.promptForNewStudentInfo();
|
|
|
|
// la.display();
|
|
la.displayComplete();
|
|
|
|
std::cout << "------------" << std::endl;
|
|
List<BaseRecord *> recordPtrList;
|
|
|
|
recordPtrList.append(new LateRecord(122333, "hhhh", 10394, "aneiei"));
|
|
recordPtrList.append(new AbsentRecord(123994994, "aadkfk", 129939948, "adiorrr"));
|
|
recordPtrList.append(new PersonalLeaveRecord(132934949, "mumu", 129293, "s999"));
|
|
ListDisplay displayer(recordPtrList);
|
|
displayer.display();
|
|
Iterator<BaseRecord *> it = recordPtrList.iterate();
|
|
while (it) {
|
|
delete it.next();
|
|
}
|
|
return 0;
|
|
} |