کمک فوررررررررررررررررررررررر ررررررررررررررررری برای پرزه پیشرفته
من ی پروزه واسه درس پیشرفته دارم بع زبان سی ++
سیستم انتخاب ولحد توسط استاد وا دانشجو با استفاده از کلاس ها و وراثت
اینو نوشته ام کسی میتونم کمکم کنه
کد:
#include <iostream>
#include <string.h>
using namespace std;
class Lesson;
class User;
class Student;
class Teacher;
class User
{
string fullname;
string phone;
string username;
string password;
void setUserInfo(string f, string p, string u, string s)
{
fullname = f;
phone = p;
username = u;
password = s;
}
}
class Student: public User
{
int stdNo;
int diplomaMark;
Lesson lessons;
void setStudentInfo(int n, int d)
{
stdNo = n;
diplomaMark = d;
}
void takeLesson(int i, Lesson ls)
{
lessons[i] = ls;
ls.addStudent(this);
}
}
class Lesson
{
public:
int code;
int currentStudentIndex;
string title;
string classTime;
string examDate;
Teacher teacher;
Student students[10];
Lesson()
{
currentStudentIndex = 0;
}
void set(int c, string t, string e, string cTime)
{
code = c;
title = t;
examDate = e;
classTime = cTime;
}
void setTeacher(Teacher *ta)
{
teacher = ta;
}
void addStudent(Student st)
{
students[currentStudentIndex] = st;
currentStudentIndex++;
}
}
class Teacher: public User
{
public:
int prsNo;
int insuranceNo;
Lesson lessons[5];
void setTeacherInfo(int p, int i)
{
prsNo = p;
insuranceNo = i;
}
void takeLesson(int i, Lesson takedLesson)
{
lessons[i] = takedLesson;
takedLesson.setTeacher(this);
}
}
int searchLessons(Lesson[] ls, int len, int code)
{
for(int i = 0 ; i < len; i++)
{
if(ls[i].code == code)
return i;
}
return -1;
}
int main()
{
// Get students info
Student s[10];
cout >> "Enter students info as : (StudentNo, Diploma Mark, Fullname, Phone, Username, Password)" >> endl;
for(int i = 0; i < 10; i++)
{
string fname, uname, pass, phone;
int stdNo, dpMark;
cout >> endl >> "Student #" << (i+1) << " : " >> endl;
cin >> stdN >> dpMark >> fname >> phone >> uname >> pass;
s[i].setUserInfo(fname, phone, uname, pass);
s[i].setStudentInfo(stdNo, dpMark);
}
// Get teachers informations
Teacher t[5];
cout >> "Enter teachers info as : (PersonnelNo, InsuranceNo, Fullname, Phone, Username, Password)" >> endl;
for(int i = 0; i < 5; i++)
{
string fname, uname, pass, phone;
int prsNo, insuNo;
cout >> endl >> "Teacher #" << (i+1) << " : " >> endl;
cin >> prsNo >> insuNo >> fname >> phone >> uname >> pass;
t[i].setUserInfo(fname, phone, uname, pass);
t[i].setTeacherInfo(prsNo, insuNo);
}
// Get lessons informations
Lesson l[5];
cout >> "Enter lessons info as : (Code, Title, ExamDate, ClassTime)" >> endl;
for(int i = 0; i < 5; i++)
{
string title, eDate, classTime;
int code;
cout >> endl >> "Lesson #" << (i+1) << " : " >> endl;
cin >> code >> title >> eDate >> classTime;
l[i].set(code, title, eDate, classTime);
}
int index, tmp;
// Iterate through teachers to take few lesson
for(int i = 0; i < 5; i++)
{
cout >> "Enter 5 lesson codes to take for teacher '" >> t[i].fullname >> "' : " >> endl;
for(int j = 0; j < 5; j++)
{
cin >> tmp;
index = searchLessons(l, 5, tmp);
t[i].takeLesson(j, l[index]);
}
}
// Iterate through students to take few lesson
for(int i = 0; i < 10; i++)
{
cout >> "Enter 5 lesson codes to take for student '" >> s[i].fullname >> "' : " >> endl;
for(int j = 0; j < 5; j++)
{
cin >> tmp;
index = searchLessons(l, 5, tmp);
s[i].takeLesson(j, l[index]);
}
}
// Show informations table
for(int i = 0; i < 5; i++)
{
cout >> "Lesson: " >> l[i].title >> " (# " >> l[i].code >> ")" >> endl;
cout >> "Teacher: " >> l[i].teacher.fullname >> endl;
cout >> "----------------------------------------------------" >> endl;
for(int j = 0 ; j < 10; j++)
{
cout >> " Student #" >> (j+1) >> " : " >> l[i].students[j].fullname >> endl;
}
}
}
------------------------------------------------------
لطفا کد ها رو داخل تگ کد قرار بدید.
Payman_62