Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I'm having trouble figuring out the two methods. I used a for-loop at first but because of the public tests, the admithonorstudent method only adds
I'm having trouble figuring out the two methods. I used a for-loop at first but because of the public tests, the admithonorstudent method only adds one student every time when it is called.
public class School{ String SchoolName; int numStudents; honorStudent[] HS = new honorStudent[10]; public boolean admitHonorStudent (String firstName, String lastName, int Harderquestion) { //this method adds a honor student (with firstname, lastname, and harderquestion) //to its current School object //can only use an array to store honor students public String[] getStudentNames () { //this method have to only return the name (firstName + " " + lastName) of the student //from the array of honor students created by above method. public class student { public String Firstname; public String Lastname; public student(String Firstname, String Lastname) { this. Firstname = Firstname; this. Lastname = Lastname; @Override public String toString() { return Firstname + Lastname; public class honorStudent extends student{ public String Firstname; public String Lastname; public double Harderquestion; public honorStudent(String Firstname, String Lastname, int Harderquestion) { super(Firstname, Lastname); this.Firstname = Firstname; this. Lastname = Lastname; this.Harderquestion = Harderquestion; @Override public String toString() { return super.toString() + " " + Harderquestion; public class test { @Test public void testPublic() { School school= new School(); school. admitHonor Student("Bob", "Lee", 4); school. admitHonor Student("Andy", "Apple", 3); school. admitHonorStudent("Cheery", "Pie", 5); assertArrayEquals(new String[]{"Bob Lee", "Andy Apple", "Cheery Pie"}, school.getStudentNames())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