Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My code keeps terminating when I compile it lab1.School@7852e922 School.java package lab1; public class School { private String schoolName; public School(String schoolName) { this.schoolName =

My code keeps terminating when I compile it

"lab1.School@7852e922"

School.java

package lab1; public class School {

private String schoolName;

public School(String schoolName) { this.schoolName = schoolName; }

public String getSchoolName() { return this.schoolName; }

public void setSchoolName(String schoolName) { this.schoolName = schoolName; }

public static void main(String[] args) {

School hogwarts = new School("Hogwarts School of Witchcraft and Wizardry"); House gryffindor = new House("Gryffindor", "RED"); House slytherin = new House("Slytherin", "GREEN"); House hufflepuff = new House("Hufflepuff", "YELLOW"); House ravenclaw = new House("Ravenclaw", "BLUE");

Student harryPotter = new Student("Harry Potter", 2); Student ronaldWeasley = new Student("Ron Weasley", 2); Student dracoMalfoy = new Student("Draco Malfoy", 2); Student lunaLovegood = new Student("Luna Lovegood", 1); Student cedricDiggory = new Student("Cedric Diggory", 3);

gryffindor.addStudent(harryPotter); gryffindor.addStudent(ronaldWeasley); slytherin.addStudent(dracoMalfoy); ravenclaw.addStudent(lunaLovegood); hufflepuff.addStudent(cedricDiggory);

hogwarts.addHouse(gryffindor); hogwarts.addHouse(slytherin); hogwarts.addHouse(hufflepuff); hogwarts.addHouse(ravenclaw);

System.out.println(hogwarts); }

private void addHouse(House house) {

}

}

House.java

package lab1;

public class House {

String houseName; String houseColor; String[] studentArray = new String[9];

public House(String houseName, String houseColor) { this.houseName = houseName; this.houseColor = houseColor; }

public String getHouseName() { return this.houseName; }

public void setHouseName(String houseName) { this.houseName = houseName; }

public String getHouseColor() { return this.houseColor; }

public void setHouseColor(String houseColor) { this.houseColor = houseColor; }

public void addStudent(Student studentName) {

} }

Student.java

package lab1;

public class Student {

String studentName; int studentYear;

public Student(String studentName, int studentYear) { this.studentName = studentName; this.studentYear = studentYear; }

public String getStudentName() { return this.studentName; }

public void setStudentName(String studentName) { this.studentName = studentName; }

public int getStudentYear() { return this.studentYear; }

public void setStudentYear(int studentYear) { this.studentYear = studentYear; }

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago