Need help to create general class
Complete Class Structure of the given description:
abstract class Ticket
{
protected enum Format {ADULT, CHILD, EMPLOYEE,
MOVIEPASS};
protected Format typeOfTicket;
protected double priceOfTicket;
protected int ageOfPerson;
protected int idOfPerson;
public Ticket()
{}
public Ticket(Format typeOfTicket, double
priceOfTicket, int ageOfPerson, int idOfPerson)
{
this.typeOfTicket =
typeOfTicket;
this.priceOfTicket =
priceOfTicket;
this.ageOfPerson =
ageOfPerson;
this.idOfPerson = idOfPerson;
}
public Format getTypeOfTicket()
{
return typeOfTicket;
}
public void setTypeOfTicket(Format typeOfTicket)
{
this.typeOfTicket =
typeOfTicket;
}
public double getPriceOfTicket()
{
return priceOfTicket;
}
public void setPriceOfTicket(double
priceOfTicket)
{
this.priceOfTicket =
priceOfTicket;
}
public int getAgeOfPerson()
{
return ageOfPerson;
}
public void setAgeOfPerson(int ageOfPerson)
{
this.ageOfPerson =
ageOfPerson;
}
public int getIdOfPerson()
{
return idOfPerson;
}
public void setIdOfPerson(int idOfPerson)
{
this.idOfPerson = idOfPerson;
}
@Override
public String toString()
{
return "Ticket [typeOfTicket=" +
typeOfTicket + ", priceOfTicket=" + priceOfTicket + ",
ageOfPerson="
+ ageOfPerson + ", idOfPerson=" + idOfPerson +
"]";
}
public abstract double
calculateTicketPrice();
public abstract int getId();
}
class Adult extends Ticket
{
public Adult()
{
super();
}
public Adult(Format typeOfTicket, double
priceOfTicket, int ageOfPerson, int idOfPerson)
{
super(typeOfTicket, priceOfTicket,
ageOfPerson, idOfPerson);
}
@Override
public double calculateTicketPrice()
{
return 0;
}
@Override
public int getId()
{
return -1;
}
@Override
public String toString()
{
return "Adult [typeOfTicket=" +
typeOfTicket + ", priceOfTicket=" + priceOfTicket + ",
ageOfPerson="
+ ageOfPerson + ", idOfPerson=" + idOfPerson +
"]";
}
}
class Child extends Ticket
{
public Child()
{
super();
}
public Child(Format typeOfTicket, double
priceOfTicket, int ageOfPerson, int idOfPerson)
{
super(typeOfTicket, priceOfTicket,
ageOfPerson, idOfPerson);
}
@Override
public double calculateTicketPrice()
{
return 0;
}
@Override
public int getId()
{
return -1;
}
@Override
public String toString()
{
return "Child [typeOfTicket=" +
typeOfTicket + ", priceOfTicket=" + priceOfTicket + ",
ageOfPerson="
+ ageOfPerson + ", idOfPerson=" + idOfPerson +
"]";
}
}
class Employee extends Ticket
{
public Employee()
{
super();
}
public Employee(Format typeOfTicket, double
priceOfTicket, int ageOfPerson, int idOfPerson)
{
super(typeOfTicket, priceOfTicket,
ageOfPerson, idOfPerson);
}
@Override
public double calculateTicketPrice()
{
return 0;
}
@Override
public int getId()
{
return 0;
}
@Override
public String toString()
{
return "Employee [typeOfTicket=" +
typeOfTicket + ", priceOfTicket=" + priceOfTicket + ",
ageOfPerson="
+ ageOfPerson + ", idOfPerson=" + idOfPerson +
"]";
}
}
class MoviePass extends Ticket
{
public MoviePass()
{
super();
}
public MoviePass(Format typeOfTicket, double
priceOfTicket, int ageOfPerson, int idOfPerson)
{
super(typeOfTicket, priceOfTicket,
ageOfPerson, idOfPerson);
}
@Override
public double calculateTicketPrice()
{
return 0;
}
@Override
public int getId()
{
return 0;
}
@Override
public String toString()
{
return "MoviePass [typeOfTicket=" +
typeOfTicket + ", priceOfTicket=" + priceOfTicket + ",
ageOfPerson="
+ ageOfPerson + ", idOfPerson=" + idOfPerson +
"]";
}
}
Need help to create general class Classes Data Element - Ticket Create an abstract class called...
Ticket Hierarchy Ticket Abstract Class Create a static variable called nextTicketId. This is an integer representing the next available integer for the ticketId private static int nextTicketId = 1000; getPrice method: Abstract method that returns a double. NOTE: Do not make price an instance variable in Ticket. Noargument constructor: Sets event name to “none”, event location to “none”, and ticket id to 0. Create a constructor that accepts the event name and event location as parameters. Set the ticket Id...
Create an abstract class “Appointment” that represents an event on a calendar. The “Appointment” class will have four instance variables: • An instance variable called “year” which will be of type int • An instance variable called “month” which will be of type int • An instance variable called “day” which will be of type int • An instance variable called “description” which will be of type String The “Appointment” class must also implement the following methods: • A getter...
In this assignment, you will implement Address and Residence classes. Create a new java project. Part A Implementation details of Address class: Add and implement a class named Address according to specifications in the UML class diagram. Data fields: street, city, province and zipCode. Constructors: A no-arg constructor that creates a default Address. A constructor that creates an address with the specified street, city, state, and zipCode Getters and setters for all the class fields. toString() to print out all...
Java Problem 2: Employee (10 points) (Software Design) Create an abstract class that represents an Employee and contains abstract method payment. Create concrete classes: SalaryEmployee, CommissionEmployee, HourlyEmployee which extend the Employee class and implements that abstract method. A Salary Employee has a salary, a Commision Employee has a commission rate and total sales, and Hourly Employee as an hourly rate and hours worked Software Architecture: The Employee class is the abstract super class and must be instantiated by one of...
java language Problem 3: Shape (10 points) (Software Design) Create an abstract class that represents a Shape and contains abstract method: area and perimeter. Create concrete classes: Circle, Rectangle, Triangle which extend the Shape class and implements the abstract methods. A circle has a radius, a rectangle has width and height, and a triangle has three sides. Software Architecture: The Shape class is the abstract super class and must be instantiated by one of its concrete subclasses: Circle, Rectangle, or...
JAVA :The following are descriptions of classes that you will create. Think of these as service providers. They provide a service to who ever want to use them. You will also write a TestClass with a main() method that fully exercises the classes that you create. To exercise a class, make some instances of the class, and call the methods of the class using these objects. Paste in the output from the test program that demonstrates your classes’ functionality. Testing...
Implement an abstract class named Person and two subclasses named Student and Staff in Java. A person has a name, address, phone number and e-mail address. A student has a credit hour status (freshman, sophomore, junior, or senior). Define the possible status values using an enum. Staff has an office, salaray, and date-hired. Implement the above classes in Java. Provide Constructors for classes to initialize private variables. Getters and setters should only be provided if needed. Override the toString() method...
List of Candles Create a class called CandleNode which has fields for the data (a Candle) and next (CandleNode) instance variables. Include a one-argument constructor which takes a Candle as a parameter. (For hints, see the PowerPoint on "Static vs. Dynamic Structures”.) public CandleNode (Candle c) { . . } The instance variables should have protected access. There will not be any get and set methods for the two instance variables. Create an abstract linked list class called CandleList. This...
Create a NetBeans project called "Question 1". Then create a public class inside question1 package called Author according to the following information (Make sure to check the UML diagram) Author -name:String -email:String -gender:char +Author(name:String, email:String, gender:char) +getName():String +getEmail):String +setEmail (email:String):void +getGender():char +tostring ):String . Three private instance variables: name (String), email (String), and gender (char of either 'm' or 'f'): One constructor to initialize the name, email and gender with the given values . Getters and setters: get Name (), getEmail() and getGender (). There are no setters for name and...
Write a program that meets the following requirements: Sandwich Class Create a class called Sandwich which has the following instance variables. No other instance variables should be used: - ingredients (an array of up to 10 ingredients, such as ham, capicola, American cheese, lettuce, tomato) -condiments (an array of up to 5 condiments, such as mayonnaise, oil, vinegar and mustard) Create a two argument constructor Write the getters and setters for the instance variables Override the toString method using the...