Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA HW HELP THANK YOU! In the next questions, write a complete class definition

ID: 3680741 • Letter: J

Question

JAVA HW HELP THANK YOU!

In the next questions, write a complete class definition for a class called HighSchool, which is a child class of the School class you just wrote.

A HighSchool is described by its name, whether or not it is private, and the number of grades in the school.

Use good principles of class design, encapsulation, and inheritance. Reuse code whenever possible.

Question 1

Write the class header and the instance data variables for the HighSchool class.

Question 2

Write two constructors:

a default (no-argument) constructor sets the name of the school to the text "UNKNOWN," sets private to false, and sets the number of grades to 0

a second constructor sets the name, private status, and number of grades based on a parameters

Question 3

Write appropriate getter/setter methods.

Question 4

Write a toString method with the following formatting

Name: Mission High (4 grades, private)

Name: Valley High (3 grades)

The word "private" is included only if the high school is private. If it is not, no private status information is included.

Question 5

Write an equals method. Two high schools are logically equivalent if they have the same name (ignoring capitalization), number of grades, and private status.

Question 6

Have the HighSchool class implement the Comparable interface.

Write the new class header.

Write the full compareTo method. High schools are ordered first by name, then by the number of students.

Question 7

Write code that would go inside of a main method.

Creates an array of four School objects that contain two schools and two high schools.

Use a loop to print a text representation of each object.

Use a loop and polymorphism to count the number of private high schools in the array.

Explanation / Answer

/*

    class header and the instance data variables for the HighSchool class.

*/

public class HighSchool extends School{

private String Name;

private double No_grades;

// constructor

public HighSchool(string name , double no_grades)

{

      this.name = UNknown;

      this.No_grades= 0;

}

//*

   Retrieves the name of the HighSchool

    @return name

*//

public String getName() {

    return Name;

}

public double getGrade(){

       return Grade;

}

public void setName(String Name) {

this.Name = Name;

}

public void setgrade(String grade) {

   this.Grade=grade;

}

public String toString()

{

return Name + " " + grade+ " " + getgrade();

}

}

}