Exemplo n.º 1
0
int main(void)
{
   Student stu;
    stu.setName("answer");
    stu.setGender("男");
    stu.initScore();
    stu.study(10);
    cout<<stu.getName()<<" "<<stu.getGender()<<" "<<stu.getScore()<<endl;
    
    return 0;
}
Exemplo n.º 2
0
// Enter Information Menu.
char entermenu(istream& is) {

	system("cls");
	Person person;
	Student student;

	int ec;

	do {
		cout << endl;
		cout << setw(25) << left << "   Enter Information" << endl;
		cout << setw(25) << setfill('-') << "" << endl;

		cout << setw(25) << setfill(' ') << "1. Create Personal Profile" << endl;
		cout << setw(25) << "2. Add Student Information" << endl;
		cout << setw(25) << "3. Add Work Information" << endl;
		cout << setw(25) << "4. Back to Main menu" << endl << endl;

		cout << setw(25) << "Please select an option: ";
        
		cin >> ec;
		cin.ignore();

		switch(ec) {
		case 1:
			person.menu();
			break;
		case 2:
			// Add Student Information.
			student.addStudentInfo();
			break;
		case 3:
			// Add Work Information.
			break;
		case 4:
			break;
		}

	} while (ec != 4);


	return ec;

}
Exemplo n.º 3
0
int main(){
    Student s1("张飞",28);
    s1.Print();
    /**
     * 这种方式的话,s1里的m_pszName和s2中的m_pszName是一样的,都是地址值,当s1离开作用域的时候
     * 会调用析构函数,当s2离开作用的时候也会调用析构函数,这样的话,就会double
     * free,释放了两次
     */
    Student s2(s1);
    s2.Print();
#if 0
    Student s3 = s2;
    s3.Print();
    Student *ps = new Student(s3);
    ps->Print();
    delete ps;
#endif
    return 0;
}
Exemplo n.º 4
0
void Expectations::updateExpComboBox()
{
    expSelect_->clear();

    Student* student = UTManager::instance().student();
    if(!student)
        return;

    const QList<Expectation*> &exp = student->exp();
    for(int i = 0; i < exp.size(); i++)
    {
        expSelect_->addItem(exp.at(i)->name());
    }

    expSelect_->insertItem(0,"Nouvelle prévision");
    expSelect_->setCurrentIndex(0);

    createExpPanel();
}
Exemplo n.º 5
0
void Database::Search(string sType, string sValue){
                                                                               // simple but horribly inefficent search function
  bool foundValue = false;
  int size = Database::iTotalStudents;

  for(int i = 0; i < size; i++){

    Student newStudent = Student();
    newStudent = Database::getStudentOffArray(i);

    if(sType == "last"){
      if(newStudent.getLastName() == sValue){
	foundValue = true;
	cout <<"\nFound a match for " << sValue << endl;
	cout << newStudent;
      }//end if

    } else if (sType == "first"){

      if(newStudent.getFirstName() == sValue){
	foundValue = true;
	cout <<"\nFound a match for " << sValue << endl;
	cout << newStudent;
      }//end if

    } else if (sType == "city"){

      Address newAddress = Address();
      newAddress = newStudent.getAddress();

      if(newAddress.getCity() == sValue){
	foundValue = true;
	cout <<"\nFound a match for " << sValue << endl;
	cout << newStudent;
      }//end if
    }//end if
  }//end for

    if(!foundValue){
      cout << "\n*****************************String not found." << endl;
    }//end if

}//end method
Exemplo n.º 6
0
int main()
{
	Person * p = new Student;
	Student * s = new Student;
	Student * gs = new GradStudent;
	Person * ps = new GradStudent;
	
	p->aboutMe();
	s->aboutMe();
	gs->aboutMe();
	ps->aboutMe();
	
	delete p;
	delete s;
	delete gs;
	delete ps;
	
	return 0;
}
Exemplo n.º 7
0
void 
print_list()
{
	int i;
	const LinkedList &sList = master_student_list();  //local reference to student list.
	const LinkedList &cList = master_course_list();	  //local reference to course list.
	Student *studentPtr;  // local pointer to student object
	Course *coursePtr;	  // local pointer to course object
	
	if (sList.size() <= 0)  // Attempts to acces an empty list are avoided.
		cerr << "\n*** No Students in the List ***\n" << endl;
		
	if (sList.size() > 0)
	{
		cout << "\nSTUDENTS CURRENTLY IN THE DATABASE" << endl;
		// Print out the student objects.
		for (i = 0; i < sList.size(); i++)
		{
			// Get a student object from the list
			studentPtr = (Student*)sList[i]; // uses operator overloading for '[]'
	
			// Now print the student using the print behaviour of the student object.
			studentPtr->print();
		}
	}

	if (cList.size() <= 0)  // Attempts to acces an empty list are avoided.
		cerr << "\n*** No Courses in the List ***" << endl;

	if (cList.size() > 0)
	{
		cout << "ENROLLMENT FOR ALL COURSES IN THE DATABASE\n" << endl;
		// Print out the course objects.
		for (i = 0; i < cList.size(); i++)
		{
			// Get a course object from the list
			coursePtr = (Course*)cList[i];

			// Now print the course using the print behaviour of the course object.
			coursePtr->print();
		}
	}
}
Exemplo n.º 8
0
void main()
{  int i;
   string w;
	cout << "Lesson1:  Encapsulation - Scope Resolution"<< endl ;
	a.initialize ();
	b.initialize ();

	cout <<"Enter Student name : " ; getline(cin,w);	
	strcpy(a.name,w.c_str());
	if (a.name[0]=='\0')  // if the name is empty
		return;
	printf("Enter # of credits : " );	cin >>a.credits ; // scanf("%d", &a.credits );

	a.add_new_course("CS 3397",2);
	a.add_new_course("CS 2410",3);
	a.display_info();
	for (i=0 ; i<8 && a.crs[i].ID[0]; i++ )
		a.crs[i].display_info();
}
Exemplo n.º 9
0
int main()
{
  ofstream data;
  data.open("Student.dat",ios::out|ios::binary);

  char name[20], id[10], department[20], address[20];
  char ans;

  do
  {
    cout << "Enter Student information" << endl;
    cout << "Name: ";
    cin >> name;
    cout << "Id: " ;
    cin >> id;
    cout << "Department: " ;
    cin >> department;
    cout << "Address: " ;
    cin >> address;

    Student newStudent(name,id,department,address);

    data.write(reinterpret_cast<char *>(&newStudent),sizeof(newStudent));
    cout << "Do you want to continue adding student data y/n";
    cin >> ans;
  }
  while(ans == 'y');
  data.close();
 
  ifstream info;
  info.open("Student.dat",ios::in|ios::binary);
  while(!info.eof()) 
  {
    Student newStudent;
    info.read(reinterpret_cast<char *>(&newStudent),sizeof(newStudent));
    if (info)
      newStudent.display();
  }
  info.close();
  
  return SUCCESS;
}
Exemplo n.º 10
0
int StudentDao::callBackGetAllStudents(void *, int elementCount, char **element, char **colName)
{
	Student student;
	student.setUid(element[0] ? element[0] : "NULL");
	student.setName(element[1] ? element[1] : "NULL");
	student.setSex(element[2] ? element[2] : "NULL");
	student.setCredit(element[3] ? element[3] : "NULL");
	student.setGrade(element[4] ? element[4] : "NULL");
	student.setMajor(element[5] ? element[5] : "NULL");
	student.setDepartment(element[6] ? element[6] : "NULL");
	students.push_back(student);
	return 0;
}
Exemplo n.º 11
0
float Course::Getstudentgrade(Student& s){
	int i;
	Node* p;p=studentlist;
	for(i=0;i<studentnum;i++){
		if(strcmp(s.Getname(),p->Studentname)==0)
			return p->grade;
		p=p->next;
	}
	cout<<"can't find student"<<endl;
	return 0;
}
Exemplo n.º 12
0
int main() {
    int age, standard;
    string first_name, last_name;

    cin >> age >> first_name >> last_name >> standard;

    Student st;
    st.set_age(age);
    st.set_standard(standard);
    st.set_first_name(first_name);
    st.set_last_name(last_name);

    cout << st.get_age() << "\n";
    cout << st.get_last_name() << ", " << st.get_first_name() << "\n";
    cout << st.get_standard() << "\n";
    cout << "\n";
    cout << st.to_string();

    return 0;
}
Exemplo n.º 13
0
void Course::Setgrade(Student& s,float a){
	int i;
	Node* p;p=studentlist;
	for(i=0;i<studentnum;i++){
		if(strcmp(s.Getname(),p->Studentname)==0){
			p->grade=a;
		cout<<"scessfully"<<endl;
		exit(0);
		}
	}
}
Exemplo n.º 14
0
int ClassMember::average(QMap<QDateTime, Session *> *sessions)
{
    long double score = 0.0;
    long double maxscore = 0.0;
    for (int i = 0; i < ms_sessions.count(); ++i) {
        Session *session = sessions->value(ms_sessions.at(i).session, NULL);
        if (session == NULL)
            continue;
        if (ms_sessions.at(i).member_num < 0 || ms_sessions.at(i).member_num >= session->numStudents())
            continue;
        Student *student = session->student(ms_sessions.at(i).member_num);
        score += student->score();
        maxscore += student->maximumScore();
    }
    if (score == 0.0)
        return 0;
    if (maxscore == 0.0)
        return 100;
    return (int)(100.0 * score / maxscore);
}
Exemplo n.º 15
0
int dispStudentRecord(){		//Display all Student Records
	Student obj;
	int v=0;
	fstream fl(FLBSTUD, ios::in|ios::binary);
	if(!fl){					//If file does not exist
		cout<<"Empty Records !\n";
		return 0;
	}
	while(!fl.eof()){
		fl.read((char*)&obj, sizeof(obj));
		if(fl.eof())
			break;
		v=1;
		obj.printDetails();
		RULE('-');
	}
	fl.close();
	if(!v)
		cout<<"Empty Records !\n";
	return v;
}
std::size_t list_length(const Student<Item>& head_ptr)
    // Library facilities used: cstdlib
{
	const Student<Item> *cursor;
	std::size_t answer;
	
	answer = 0;
	for (cursor = head_ptr.get(); cursor != NULL; cursor = cursor->link( ))
	    ++answer;
	
	return answer;
}
Exemplo n.º 17
0
Student* fn()
{
    // create a student and initialize it
    cout << "Constructing a local student in fn()" <<endl;
    Student student("Stephen Davis", 1234);

    // display the student's name
    cout << "The student's name is "
         << student.getName() << endl;

    // now allocate one off of the heap
    cout << "Allocating a Student from the heap" << endl;
    Student *pS = new Student("Kinsey Davis", 5678);

    // display this student's name
    cout << "The second student's name is "
         << pS->getName() << endl;

    cout << "Returning from fn()" << endl;
    return pS;
}
Exemplo n.º 18
0
//-------------------------------------
void fn(Student& x){
  switch(x.type){
    case Student::STUDENT:
      x.calcTuition(); break;
    case Student::GRADUATESTUDENT:{
      GraduateStudent& gx = static_cast<GraduateStudent&>(x);
      gx.calcTuition(); break;}
    case Student::DOCTOR:{
      Doctor& dx = static_cast<Doctor&>(x);
      dx.calcTuition(); break;}
  }
}//------------------------------------
Exemplo n.º 19
0
void Tree::DeleteNode(TreeNode *&pTree){

    Student data;
    TreeNode* temp;

    temp = pTree;

    if(pTree->m_left == nullptr){
        pTree = pTree->m_right;
        delete temp;
    }
    else if(pTree->m_right == nullptr){
        pTree = pTree->m_left;
        delete temp;
    }
    else{
        GetPredecessor(pTree->m_left,data);
        pTree->m_student = data;
        Delete(data.getID(),pTree->m_left);
    }
}
Exemplo n.º 20
0
void TeachRegManager::addStudentName(const QString &studentName, int groupId)
{
	QMap<int, QStringList> lrMap;
	QMap<int, QStringList> prMap;
	int lectureDatesCount = 0, practicDatesCount = 0;
	
	Student st;
	st.setName(studentName);
	st.setSubgroupId(1);
	
	Group *gr = db->getGroupPtr(groupId);
	st.setParent(gr);
	
	for(int i = 0; i < db->getDisciplinList().count(); i++)
	{
		lectureDatesCount = gr->getLectureDate(i).count();
		practicDatesCount = gr->getPracticDate(i * 10 + 1).count();
		QStringList lect;
		QStringList prac;
		for(int j = 0; j < lectureDatesCount; j++)
			lect << "0";
		for(int j = 0; j < practicDatesCount; j++)
			prac << "0";
		
		lrMap.insert(i, lect);
		prMap.insert(i, prac);
	}
	
	st.setLectureResultsMap(lrMap);
	st.setPracticResultsMap(prMap);
	gr->addStudent(st);
}
Exemplo n.º 21
0
void AcademyGroup::Load(){
	FILE* fs = NULL;
	char* path = "AcademyGroup";
	fopen_s(&fs, path, "rb");	if (fs == 0) exit(0);

	int tmp, tmpCont;
	char buf[100];
	double tmpD;
	Student obj;
	fread(&tmpCont, sizeof(tmpCont), 1, fs);

	for (int i = 0; i < tmpCont; i++){

		fread(&tmp, sizeof(int), 1, fs);
		fread(buf, sizeof(char), tmp, fs);
		obj.setName(buf);

		fread(&tmp, sizeof(int), 1, fs);
		fread(buf, sizeof(char), tmp, fs);
		obj.setSurname(buf);

		fread(&tmp, sizeof(int), 1, fs);
		obj.setAge(tmp);

		fread(&buf, sizeof(char), 12, fs);
		obj.setPhone(buf);

		fread(&tmpD, sizeof(double), 1, fs);
		obj.setAverage(tmpD);

		this->AddStudents(obj);
	}

	fclose(fs);
}
Exemplo n.º 22
0
void AuthenticationMenu(){
	IStorage * fs = new FileStorage();
	// ---------------------------------------------------------------------------
	//** user local vars
	string userName;
	string userLastName;
	int userId;
	//	Student stud;
	// ---------------------------------------------------------------------------


	//Student stud = Student::getStudentById(fs, 12311);
	lOGO

		cout << "Please enter the following details" << endl;
	cout << "Name: ";
	cin >> userName;
	cout << "\nLast name: ";
	cin >> userLastName;
	cout << "\nId: ";

	while (!(cin >> userId) || userId < 0) // <<< note use of "short circuit" logical operation here
	{
		cout << "Bad input - try again: ";
		cin.clear();
		cin.ignore(INT_MAX, '\n'); // NB: preferred method for flushing cin
	}


	Student * stud = Student::getStudentByStudentId(fs, 2 /*userId*/);
	if (stud->getFirstName() == "John" /*userName*/ && stud->getLastName() == "The I"/*userLastName*/){
		//if(stude.getCounter == 3 ) student locked --- else...
		if (stud->verifyPassword("password@1")){
			cout << "Authenticate succeed" << endl;
			CLEAN
				LogInMenu(fs);
		}
		//else counter++
	}
}
Exemplo n.º 23
0
bool UsersGroupsManager::update_list_browse() {
    /** METHOD TO UPDATE THE LISTS (BROWSING AND LINKING) **/
    // Clear the list
    ui->list_browse->clear();

    /// Adapt the variables and labels according the chosen method to link students and groups
    bool browseStd = (ui->comboBox_browse->currentData().toInt() == BrowseStudents);
    QList<qulonglong>* listToTreat = NULL;
    if(browseStd) {
        // If the browsing is with students
        listToTreat = m_listStudents;
        ui->label_browse->setText("Elèves");
        ui->label_yes->setText("Groupes de l'élève");
        ui->label_no->setText("Autres groupes");
    }else {
        // If the browsing is with groups
        listToTreat = m_listGroups;
        ui->label_browse->setText("Groupes");
        ui->label_yes->setText("Elèves du groupe");
        ui->label_no->setText("Autres élèves");
    }

    /// Fill the browsing list
    for(int i=0; i<listToTreat->count(); i++) {
        // Get the text for the item
        QString text = "";
        if(browseStd) {
                Student* std = (Student*) listToTreat->at(i);
                text = std->getName() + " " + std->getFirst_name();
        } else    text = ((Group*) listToTreat->at(i))->getName() + " (" + QString::number(nbStudentsInGroup(((Group*) listToTreat->at(i))->getId()))+ ")";
        // Create the item with the element
        QListWidgetItem *item = new QListWidgetItem(text, ui->list_browse);
        item->setData(Qt::UserRole, (qulonglong) listToTreat->at(i));
    }

    /// Update the linking lists (lists YES and NO)
    update_listsYesNo();

    return true;
}
Exemplo n.º 24
0
void viewmenu() {
	system("cls");
	Person person;
	Student student;

	int ec;

	do {
		cout << endl;
		cout << setw(25) << left << "    View Information" << endl;
		cout << setw(25) << setfill('-') << "" << endl;

		cout << setw(25) << setfill(' ') << "1. View Personal Profile" << endl;
		cout << setw(25) << "2. View Student Information" << endl;
		cout << setw(25) << "3. View Work Information" << endl;
		cout << setw(25) << "4. Back to Main menu" << endl << endl;

		cout << setw(25) << "Please select an option: ";
        
		cin >> ec;
		cin.ignore();

		switch(ec) {
		case 1:
			person.viewProfile();
			break;
		case 2:
			// Add Student Information.
			student.addStudentInfo();
			break;
		case 3:
			// Add Work Information.
			break;
		case 4:
			break;
		}

	} while (ec != 4);

}
Exemplo n.º 25
0
//三级函数 of TeaStuManage
void TeaStuAdd(void)
{
	int s, again;
	Student stuNew;
	string name; long id; string Class;
	do
	{
		do
		{
			system("cls");
			cin.clear();
			cin.sync();
			
			cout<<strTeaSA1;
			cin>>name;
			cout<<strTeaSA2;
			INPUT_INT_L(id,1);
			cout<<strTeaSA3;
			cin>>Class;

			cout<<strTeaSAConfirm1<<name<<' '<<id<<' '<<Class<<' ';
			cout<<strTeaSAConfirm2<<strStuPassword<<strTeaSAConfirm3;
			
			INPUT_INT_LU(s,0,2);
		}while(s==2);
		if(s==0)	return;
		//else  (s==1)
		stuNew.SetName(name);
		stuNew.SetId(id);
		stuNew.SetClass(Class);
		stuNew.SetPassword(strStuPassword);	//初始密码

		if(data.AddStu(stuNew))
			cout<<strTeaSAS;
		else
			cout<<strTeaSAF;	//学号冲突
		INPUT_INT_LU(again,0,1);
	}while(again==1);
	return;
}
Exemplo n.º 26
0
int DBimpl::createStudent (Student& student){
    QSqlQuery query;
    query.prepare(DatabaseQueries::insertStudent);
    query.bindValue(":username",student.getUsername());
    if(!query.exec())
    {
        qDebug() << query.lastError();
        qDebug() << query.lastQuery();
        return 0;
    }
    else {
        int lastID = query.lastInsertId().toInt();
        student.setID(lastID);
        for (int i = 0;i < student.getQualifications().count();i++)
        {
            createQualificationEntry(student.getID(),*student.getQualifications().at(i));
        }

        return lastID;
    }

}
Exemplo n.º 27
0
int main()
{
    int ch;
    //fstream f;

    Student s;
    string key;
   string filename;
    while(1)
    {
    cout<<"1.insert 2.search 3.delete 4.modify\n";
    cout<<"enter your choice";
    cin>>ch;

         switch(ch)
        {
        case 1:
            s.read();
            cout<<"enter filename ";
            cin >>filename;
            s.pack(filename.c_str());
            break;
        case 2:
            cout<<"Enter the USN to be searched\n";
            cin>>key;
            cout<<"enter filename ";
                        cin >> filename;
            s.search(key,filename);
            break;
        case 3:
            s.modify(key,filename);
            break;
        case 4:
            //s.unpack();
            break;

            }
        }
}
void list_copy(Student<Item>& source_ptr,Student<Item>& head_ptr, Student<Item>*& tail_ptr) 
{
	head_ptr = NULL;
	tail_ptr = NULL;

	// Handle the case of the empty list
	if (source_ptr == NULL)
	    return;	

	// Make the head node for the newly created list, and put data in it
	list_head_insert(head_ptr, source_ptr->data( ));
	tail_ptr = head_ptr.get(); 
	
	// Copy rest of the nodes one at a time, adding at the tail of new list
	source_ptr = source_ptr->link( ); 
        while (source_ptr != NULL)
	{
	    list_insert(tail_ptr, source_ptr->data( ));
	    tail_ptr = tail_ptr->link( );
	    source_ptr = source_ptr->link( );
	}
}
Exemplo n.º 29
0
int main(void) {
	Student s;
	while(true) {
		cout<<"Do You Want to Add Any Student Press 1 For Yes and 0 for No?:"; 
		int temp;
		cin>>temp;
		if(!temp) {
			break;
		}
		else {
			int r;
			string n;
			string dept;
			string dt;
			cout<<"Enter the Roll Number, Name, Department and Date in Order ";
			cin>>r>>n>>dept>>dt;
			s.add_student(r,n,dept,dt);
		}
	}
	while(true)  {
		cout<<"Do You want to Update Admission Date of any Student ? Yes 1 No 0 : ";
		int temp;
		cin>>temp;
		if(!temp) {
			break;
		}
		else {
			cout<<"Enter the Roll Number Followes By the New Admission date ";
			int r;
			string dt;
			cin>>r>>dt;
			s.update_admission_date(r,dt);
		}
	}
	s.receive_marks();
	s.prepare_mark_sheet();
	cout<<"Total Number of Students Admitted : "<<Student::admitted_students();
}
Exemplo n.º 30
0
	void Registrar::enrollStudentInCourse(const std::string& studentName, const std::string& courseName) {
        Student* student = nullptr;
        Course* course = nullptr;

        for (size_t i = 0; i < students.size(); i++) {
            if (students[i]->getName() == studentName) {
                student = students[i];
            }
        }

        for (size_t i = 0; i < courses.size(); i++) {
            if (courses[i]->getName() == courseName) {
                course = courses[i];
            }
        }

        if (student != nullptr && course != nullptr) {
            student->addCourse(course);
            course->addStudent(student);
        } else {
            cerr << "Unable to find student or course when enrolling student" << endl;
        }
	}