114 lines
3.7 KiB
C++
114 lines
3.7 KiB
C++
#pragma once
|
|
#include "Date.hpp"
|
|
#include "Student.hpp"
|
|
#include <ctime>
|
|
|
|
/*
|
|
The file should be in this stucture:
|
|
int totalRecordNum
|
|
unsigned nextRecordID
|
|
|
|
SaveRecord
|
|
courseName char[]
|
|
studentName char[]
|
|
|
|
SaveRecord
|
|
courseName char[]
|
|
*/
|
|
const struct {
|
|
int recordID = 10;
|
|
int date = 10;
|
|
int courseName = 15;
|
|
int studentID = 10;
|
|
int studentName = 15;
|
|
int type = 10;
|
|
} recordDisplayRowSize;
|
|
namespace StuRecord {
|
|
enum RecordType { Late, Absent, PersonalLeave, Any };
|
|
};
|
|
|
|
struct SaveRecord {
|
|
unsigned recordID;
|
|
time_t date;
|
|
unsigned long courseNameLength;
|
|
int studentNumber;
|
|
unsigned long studentNameLength;
|
|
StuRecord::RecordType recordType;
|
|
};
|
|
|
|
|
|
class BaseRecord {
|
|
protected:
|
|
unsigned recordID;
|
|
Date date;
|
|
std::string courseName;
|
|
Student student;
|
|
|
|
public:
|
|
static unsigned nextRecordID;
|
|
BaseRecord() = delete;
|
|
// Create new record
|
|
BaseRecord(const time_t _date, const std::string _courseName,
|
|
const int _studentNumber, const std::string _studentName);
|
|
// Read from file
|
|
BaseRecord(const unsigned _recordID, const time_t _date,
|
|
const std::string _courseName, const int _studentNumber,
|
|
const std::string _studentName);
|
|
virtual ~BaseRecord();
|
|
const unsigned getRecordID() const;
|
|
const Date &getDate() const;
|
|
const std::string getCourseName() const;
|
|
const int getStudentNumber() const;
|
|
const std::string getStudentName() const;
|
|
const Student &getStudent() const;
|
|
void promptForNewDate(bool showOriginal = true);
|
|
void promptForNewCourseName(bool showOriginal = true);
|
|
void promptForNewStudentInfo(bool showOriginal = true);
|
|
// Show the infomation in a line.
|
|
void display() const;
|
|
// Show the infomation in multiple lines.
|
|
void displayComplete() const;
|
|
virtual std::string getRecordTypeString() const = 0;
|
|
virtual StuRecord::RecordType getRecordType() const = 0;
|
|
virtual operator SaveRecord() const = 0;
|
|
};
|
|
|
|
class LateRecord : public BaseRecord {
|
|
public:
|
|
LateRecord(const time_t _date, const std::string _courseName,
|
|
const int _studentNumber, const std::string _studentName);
|
|
LateRecord(const unsigned _recordID, const time_t _date,
|
|
const std::string _courseName, const int _studentNumber,
|
|
const std::string _studentName);
|
|
virtual ~LateRecord();
|
|
virtual std::string getRecordTypeString() const;
|
|
virtual StuRecord::RecordType getRecordType() const;
|
|
virtual operator SaveRecord() const;
|
|
};
|
|
|
|
class AbsentRecord : public BaseRecord {
|
|
public:
|
|
AbsentRecord(const time_t _date, const std::string _courseName,
|
|
const int _studentNumber, const std::string _studentName);
|
|
AbsentRecord(const unsigned _recordID, const time_t _date,
|
|
const std::string _courseName, const int _studentNumber,
|
|
const std::string _studentName);
|
|
virtual ~AbsentRecord();
|
|
virtual std::string getRecordTypeString() const;
|
|
virtual StuRecord::RecordType getRecordType() const;
|
|
virtual operator SaveRecord() const;
|
|
};
|
|
|
|
class PersonalLeaveRecord : public BaseRecord {
|
|
public:
|
|
PersonalLeaveRecord(const time_t _date, const std::string _courseName,
|
|
const int _studentNumber,
|
|
const std::string _studentName);
|
|
PersonalLeaveRecord(const unsigned _recordID, const time_t _date,
|
|
const std::string _courseName, const int _studentNumber,
|
|
const std::string _studentName);
|
|
virtual ~PersonalLeaveRecord();
|
|
virtual std::string getRecordTypeString() const;
|
|
virtual StuRecord::RecordType getRecordType() const;
|
|
virtual operator SaveRecord() const;
|
|
}; |