Question
Do in java based on the question and code below. Use proper classes, and data types. Event code import java.text.DecimalFormat; public class Event { private
Do in java based on the question and code below. Use proper classes, and data types.
Event code
import java.text.DecimalFormat;
public class Event {
private String type;
private double price;
private int sales;
//constructors
public Event(String type, double price, int sales) {
this.type=type;
this.price=price;
this.sales=sales;
}
public void setType(String type){
this.type=type;
}
public void setPrice(double price){
this.price=price;
}
public void setSales(int sales){
this.sales=sales;
}
public String getType(){
return type;
}
public double getPrice(){
return price;
}
public int getSales(){
return sales;
}
public boolean moreSales(Event other) {
if (getSales() > other.getSales()) {
return true;
}
return false;
}
public String toString() {
DecimalFormat df = new DecimalFormat("#.00");
return ("Event: " + type + " Price: $" + df.format(price) + " Sales: " + sales);
}
}
Create a Stadium Class using the UML diagram below. Stadium - String: name - int: totalSeats - int: maxEvents - int: currEvents - Event []: events + Stadium (String, int, int): + getTotalSeats(): int + getMaxEvents(): int + getEvents(): Event [] + getName(): String + getCurrEvents(): int + setName(String): void + toString (): String + getRevenue(): double + addEvent(Event): boolean - The constructor takes in a Stadium name and an int that represents the maximum number of events, and an int that represents the totalSeats. It also initializes the array to the maximum number of events and initializes currEvents to 0 . - The method getRevenue calculates and returns the revenue from all the events in the aray. - The method addEvent will add an Event to the Stadium's array if there is room (returns true - the event was added or false the event was not added). Remember to update currEvents - The toString method return the name of the stadium, the number of seats, and the number of events. Below is an example of the output for HalifaxCentre with 10000 seats that has 25 events. | HalifaxCentre Seats: 10000 Events: 25 | HalifaxCentre Seats: 10000 Events: 25 Then create a Stadium Demo class. - Use a Scanner object to read the information to create a Stadium object - Read in an int (N) that will represent how many Events to add to the Stadium. Then read in the data for N Event objects and add it them to the Stadium (call addEvent method). - Print the Stadium object using the toString method. - Then print out all the Event objects at the Stadium. - Print the revenue from all the Event objects (hint: use printf to control the decimal places to 2 ) Note: Assume the Stadium name is all one wordStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started