Question: What is the code for this? 1 . Include phone number ( in the format xxx - xxx - xxxx ) in each record 2

What is the code for this?
1. Include 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 references in the list
4. Add method modify(int id, String lastName, String firstName, double GPA, String phone) to modify the id's record. If such id does not exist, add it as a new record into the list
class Student{
private int id;
private String firstName;
private String lastName;
private double gpa;
public Student(int in_id, String in_fName, String in_lName,
double g){
id = in_id;
firstName = in_fName;
lastName = in_lName;
gpa = g;
}
public int getID(){return id;}
public String getfName(){return firstName;}
public String getlName(){return lastName;}
public double getGPA(){return gpa;}
}
public class StudentList {
protected int length;
protected int current_pos;
protected Student[] list;
public StudentList()
{
list = new Student[100];
length =0;
current_pos =-1;
}
public StudentList(int size)
{
if(size<2) size =100;
list = new Student[size];
length =0;
current_pos =-1;
}
public void makeEmpty()
{
for(int i=0;i=list.length;
}
public int lengthIs()
{
return length;
}
private int retrieveIndex(int id)
{
boolean found = false;
int current =0;
while(!found && current

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 Programming Questions!