Hi guys, Can someone help me with my code?
View the step-by-step solution to:


Hi guys,

Can someone help me with my code? I thinking I'm doing something wrong, and would love

to have a second pair of eyes look over this.

Thank in advance.

You are to pick your own theme for a new Parent class.  You can pick from one of the following:

  • Person
  • Automobile
  • Animal

Based on your choice:

  • If you choose Person, you will Make a subclass of Person called Student.
  • If you choose Automobile, you will make a subclass of Automobile called RaceCar.
  • If you choose Animal, you will make a subclass of Animal called Horse.


Once you pick your theme, you must use the "HAS A" question to determine the fields that you are going to include in your classes.


 For example, an Alarm Clock HAS A:

  • Set Hours Button Time
  • Set Minutes Button Time
  • Set Hours Button Alarm
  • Set Minutes Button Alarm
  • Alarm On-Off Button
  • Snooze Button



  • WRITE JAVA code to create the classes from above.  In the classes you are creating you will include at least three fields or attributes (See sample alarm clock above).
  • Add overloaded methods, and overridden methods.  Label each.  Make a Test class that creates at least 3 objects of each class.
  • The parent and child classes need to have all necessary and required methods.
  • Test your work. 



  • Use global variables.
  • Use the word goto.
  • Use the break command outside a case statement.

Here what I did:

I didnt add the main because I'm still working on it, but I need to see if I'm the right path.


public class Person {

  private String firstName;

  private String lastName;

  private int age;


  public Person(String firstName, String lastName, int age) {

     this.firstName = firstName;

     this.lastName = lastName;

     this.age = age;


  public String getFirstName() {

     return firstName;


  public void setFirstName(String firstName) {

     this.firstName = firstName;


  public String getLastName() {

     return lastName;


  public void setLastName(String lastName) {

     this.lastName = lastName;


  public int getAge() {

     return age;


  public void setAge(int age) {

     this.age = age;





public class Student {


  private int rollNo;

  private double percentage;

  private String section;

  private Person person;


  public Student(String firstName, String lastName, int age, int rollNo,

        double percentage, String section) {

     person = new Person(firstName, lastName, age);

     this.rollNo = rollNo;

     this.percentage = percentage;

     this.section = section;


  public int getRollNo() {

     return rollNo;


  public void setRollNo(int rollNo) {

     this.rollNo = rollNo;


  public double getPercentage() {

     return percentage;


  public void setPercentage(double percentage) {

     this.percentage = percentage;


  public String getSection() {

     return section;


  public void setSection(String section) {

     this.section = section;


  public Person getPerson() {

     return person;


  public void setPerson(Person person) {

     this.person = person;



Top Answer

abstract class Animal { String food; int Legs; String moves; String name; public Animal()... View the full answer


Java Workspace - Java - CourseHero/src/Animal.java - Eclipse
File Edit Source Refactor Navigate Search Project Run Window Help
Quick Access: | 8 G
> CourseHero > # src > (default...

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question