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" #include  using 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" #include  using 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 #include  using 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!