hello! can you help me debug my program? it's in Java. here are my errors: line 155: void is an invalid type for the variable printOutFamilyline 126: the method content(String) is undefined for the type String here is my program: package family;   class Person { private String name; private int age;   public Person() { }   public Person(String name, int age) { this.name = name; this.age = age; }     public String toString() { return "Person [name: "+ name + ", age: " + age+ "]"; }   @Override public boolean equals(Object obj) { if(this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Person other = (Person) obj; if(age != other.age)return false; if(name == null) { if(other.name !=null) return false; } else if (!name.contentEquals(other.name)) return false; return true; }   public String getName() { return name; }   public void setName(String name)  { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; }   }   class Student extends Person { private String major; private double gpa;   public Student(String name, int age, String major, double gpa) { super(name, age); this.major = major; this.gpa = gpa; }   public Student() { }   public String getMajor()  { return major; }   public void setMajor(String major) { this.major=major; }   public double getGpa() { return gpa; }   public void setGpa(double gpa) { this.gpa = gpa; }     public String toString()  { return "Student [major: "+ major +", GPA: " +gpa + ", name: "+ getName() + ", age: " + getAge() + "]"; }   @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; Student other = (Student) obj; if(gpa != other.gpa) return false; if (major == null) { if(other.major != null) return false; } else if (!major.content(other.major)) return false; return true; }   }   public class Family  { private Person familyPersons[]; private int numPersons = 0;   public Family(int num)  { familyPersons = new Person[num]; } private void addPerson(Person p) { for (int i =0; i < numPersons; i++) { if(familyPersons[i].equals(p)) { System.out.println("Duplicate entry: "+p); return; } } if (numPersons != familyPersons.length) { familyPersons[numPersons++] = p; } else { System.out.println("Famuly array full. Skippin: " +p);   } } private void printOutFamily; { for(int i = 0; i < numPersons; i++) { System.out.println(familyPersons[i]);   }   }   private void printOutFamily() { for(int i = 0; i < numPersons; i++) { System.out.println(familyPersons[i]); } }   public static void main(String[] args) { Family f = new Family(8); Person fred = new Person("Fred Flintstone", 50); System.out.println("created " + fred); f.addPerson(fred);; f.addPerson(fred);;   Student fredStudent = new Student("Fred Flintstone", 50, "Math", 3.1); System.out.println("created "+fredStudent); f.addPerson(fredStudent);   Person wilma = new Person("Wilma Flintstone", 48); f.addPerson(wilma);;   Student george = new Student("George", 21, "politics", 3.1); System.out.println("created " + george); f.addPerson(george);   george.setName("Georgie");   f.addPerson(new Student("George", 21, "Politics", 3.1)); f.addPerson(new Student("John", 18, "Geology", 2.9)); f.addPerson(new Student("Jane", 21, "music", 3.2)); f.addPerson(new Student("Tarzan", 22, "Gymnastics", 4.0)); f.addPerson(new Student("Jim", 21, "Physics", 2.5)); f.addPerson(new Person("Robert", 18)); f.addPerson(new Person("Clemente", 32));   System.out.println("******** family listing: "); f.printOutFamily();   } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

hello! can you help me debug my program? it's in Java.

here are my errors:

line 155: void is an invalid type for the variable printOutFamily
line 126: the method content(String) is undefined for the type String

here is my program:

package family;

 

class Person {

private String name;

private int age;

 

public Person() {

}

 

public Person(String name, int age)

{

this.name = name;

this.age = age;

}

 

 

public String toString()

{

return "Person [name: "+ name + ", age: " + age+ "]";

}

 

@Override

public boolean equals(Object obj)

{

if(this == obj)

return true;

if (obj == null)

return false;

if (getClass() != obj.getClass())

return false;

Person other = (Person) obj;

if(age != other.age)return false;

if(name == null) {

if(other.name !=null)

return false;

}

else if (!name.contentEquals(other.name))

return false;

return true;

}

 

public String getName()

{

return name;

}

 

public void setName(String name) 

{

this.name = name;

}

public int getAge()

{

return age;

}

public void setAge(int age)

{

this.age = age;

}

 

}

 

class Student extends Person {

private String major;

private double gpa;

 

public Student(String name, int age, String major, double gpa)

{

super(name, age);

this.major = major;

this.gpa = gpa;

}

 

public Student()

{

}

 

public String getMajor() 

{

return major;

}

 

public void setMajor(String major)

{

this.major=major;

}

 

public double getGpa() {

return gpa;

}

 

public void setGpa(double gpa)

{

this.gpa = gpa;

}

 

 

public String toString() 

{

return "Student [major: "+ major +", GPA: " +gpa + ", name: "+ getName() + ", age: " + getAge() + "]";

}

 

@Override

public boolean equals(Object obj)

{

if (this == obj)

return true;

if (!super.equals(obj))

return false;

if (getClass() != obj.getClass())

return false;

Student other = (Student) obj;

if(gpa != other.gpa)

return false;

if (major == null)

{

if(other.major != null)

return false;

}

else if (!major.content(other.major))

return false;

return true;

}

 

}

 

public class Family 

{

private Person familyPersons[];

private int numPersons = 0;

 

public Family(int num) 

{

familyPersons = new Person[num];

}

private void addPerson(Person p)

{

for (int i =0; i < numPersons; i++)

{

if(familyPersons[i].equals(p))

{

System.out.println("Duplicate entry: "+p);

return;

}

}

if (numPersons != familyPersons.length)

{

familyPersons[numPersons++] = p;

}

else

{

System.out.println("Famuly array full. Skippin: " +p);

 

}

}

private void printOutFamily;

{

for(int i = 0; i < numPersons; i++)

{

System.out.println(familyPersons[i]);

 

}

 

}

 

private void printOutFamily()

{

for(int i = 0; i < numPersons; i++)

{

System.out.println(familyPersons[i]);

}

}

 

public static void main(String[] args) {

Family f = new Family(8);

Person fred = new Person("Fred Flintstone", 50);

System.out.println("created " + fred);

f.addPerson(fred);;

f.addPerson(fred);;

 

Student fredStudent = new Student("Fred Flintstone", 50, "Math", 3.1);

System.out.println("created "+fredStudent);

f.addPerson(fredStudent);

 

Person wilma = new Person("Wilma Flintstone", 48);

f.addPerson(wilma);;

 

Student george = new Student("George", 21, "politics", 3.1);

System.out.println("created " + george);

f.addPerson(george);

 

george.setName("Georgie");

 

f.addPerson(new Student("George", 21, "Politics", 3.1));

f.addPerson(new Student("John", 18, "Geology", 2.9));

f.addPerson(new Student("Jane", 21, "music", 3.2));

f.addPerson(new Student("Tarzan", 22, "Gymnastics", 4.0));

f.addPerson(new Student("Jim", 21, "Physics", 2.5));

f.addPerson(new Person("Robert", 18));

f.addPerson(new Person("Clemente", 32));

 

System.out.println("******** family listing: ");

f.printOutFamily();

 

}

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 8 steps with 9 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education