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

Hi, I have the following code for class Person (Person.java): public class Perso

ID: 3611277 • Letter: H

Question

Hi,

I have the following code for class Person(Person.java):

public class Person {
    private String personName;
    private int personID;
    public int ID=1;
    StadiumDeck personDeck; //public enum(StadiumDeck.java)
   
    public Person (String name)
    {
        personName = name;
        personID = ID;
        ID++;
    }
   
    public String toString()
    {
        return getName();
    }
   
    public int getID()
    {
        return personID;
    }
   
    public String getName()
    {
        return personName;
    }
   
    public void ticketLottery()
    {
        personDeck =StadiumDeck.NONE;
    }
   
    public StadiumDeck getSeat()
    {
        return personDeck;
    }
}


I want a class called Employee (Employee.java) toextend class Person. I have the following code:

import java.util.Random;

class Employee extends Person {
    private String employeeName;
    private int employeeID;
    StadiumDeck employeeDeck;
   
    public Employee (String name)
    {
        employeeName = name;
        employeeID = ID;
        ID++;
    }
   
    public String toString()
    {
        return getName();
    }
   
    public int getID()
    {
        return employeeID;
    }
   
    public String getName()
    {
        return employeeName;
    }
   
    public void ticketLottery()
    {
        Random generator = newRandom();
        int r = generator.nextInt(4)+ 1;
        if (r==1)
        {
           employeeDeck = StadiumDeck.NONE;
        }
        if (r==2)
        {
           employeeDeck = StadiumDeck.D;
        }
        if (r==3)
        {
           employeeDeck = StadiumDeck.C;
        }
        if (r==4)
        {
           employeeDeck = StadiumDeck.B;
        }
    }
   
    public StadiumDeck getSeat()
    {
        return employeeDeck;
    }
}

Question 1:
Integer ID has to be unique and be accessible byclass Employee as well. Is it ok to do public intID; for that purpose?


Question 2: Person.java compiles no problem but when I tryto compile Employee.java I get the following message:

Employee.java:9: cannot find symbol
symbol : constructor Person()
location: class Person
    {
        ^
where it points to the line with the '{' after 'public Employee(String name)' in Employee.java. Why might I be getting theerror?


Thanks!

Explanation / Answer

In your person class you have to make a call to the superconstructor. Here's the fix. public Employee(String name)     {        super(name);     }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote