Question
*Java assignment - Object Oriented Programming* 2. Write a class called Address. This class should contain street number, street name, city, and state as fields,
*Java assignment - Object Oriented Programming*
2. Write a class called Address. This class should contain street number, street name, city, and state as fields, each of which is of the type of String. Create two overloaded constructors; one has no parameters and the other uses all four parameters. Create the getters, setters and toString() methods as well. Write a class called Name. This class should contain first name, middle initial, and last name as fields, each of which is of the type of String. Create two overloaded constructors, one has no parameters and the other uses all four parameters. Create the getters, setters, and toString() methods as well. Create a class called Student. This class should contain a name (of Name type, as created above), id (unique, of int type), address (of Address type, as created above), phone number (of String type), major (of String type), and GPA (of double type)fields .Again, create a constructor, all the getters, setters, and toString() methods.
Create a class called College. This class should contain an array called students of the Student type, as created above. It should also contain the following methods:
a.public void insertStudent (Student student): to insert a student object into the students array in the College class.
b.public Student removeByid (String id): to remove a student object from the students array in the College class.
c.public student searchByid(String id): to find a student object with the given id in the students array.
d.public void display(): to display all the student objects in the college in a nicely formatted table.
then write a Demo class. In this class, you will create five Student objects. You will insert them into the college. Then test the removeByid, searchByid, and display methods.
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