Question
Modify the StudentList code we discussed in class as following: 1. Include GPA and phone number (in the format xxx-xxx-xxxx) in each record 2. No
Modify the StudentList code we discussed in class as following:
1. Include GPA and phone number (in the format xxx-xxx-xxxx) in each record
2. No duplicated ID allowed
3. Add method Swap(int id1, int id2) to swap the location of id1 and id2's record in the list
4. Add method Modify(int id, char*, char*, float, char*) to modify the id's record. If such id does not exist, add it as a new record into the list Design your own test program to test the modification. Submit your source code with your test main function
__________________________________________________________StudentListProg.cpp__________________________________________________________________________
#include "StudentList.h" #includeusing namespace std; void main() { StudentList myList; Student temp; myList.InsertItem(111,"John","Smith"); myList.InsertItem(122,"Lie","Qian"); myList.InsertItem(333,"MS","Su"); myList.InsertItem(158,"Don","Trump"); myList.InsertItem(126,"Hilary","Clinton"); temp = myList.RetrieveItem(122); cout< ____________________________________________________________StudentList.cpp___________________________________________________________
#include "StudentList.h" #includeusing namespace std; StudentList::StudentList() { length = 0; currentPos = -1; } void StudentList::MakeEmpty() { length = 0; currentPos = -1; } bool StudentList::IsFull() { if(length == MAX_ITEMS) return 1; else return 0; } int StudentList::LengthIs() { return length; } Student StudentList::RetrieveItem(int item) { int index=0; //next item to check while(index =length-1) return 1; else return 0; } Student StudentList::GetNextItem() { if(IsLastItem()) { cout<<"WARNING!!! Invalid Return from GetNextItem Function Call"< ____________________________________________________________________________________________________________________________________
_____________________________________________________________StudentList.h____________________________________________________________
#ifndef STUDENT_LIST #define STUDENT_LIST #define MAX_ITEMS 100 #includeusing namespace std; struct Student { int id; string lastName; string firstName; }; class StudentList { protected: Student list[MAX_ITEMS]; int length; int currentPos; public: StudentList(); void MakeEmpty(); bool IsFull(); int LengthIs(); Student RetrieveItem(int); bool InsertItem(int,string,string); bool DeleteItem(int); Student GetNextItem(); bool IsLastItem(); void ResetList(); void PrintAll(); }; #endif ____________________________________________________________________________________________________________________________________
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started