Objective: Write a class that keeps track of concert promotion information First
ID: 3800032 • Letter: O
Question
Objective: Write a class that keeps track of concert promotion information First down load the driver and put it in your project o Notice that this has all of the dialog outputs and user inputs already written o You are writing the backend not he front end Write a class file called Concert that DOES NOT HAVEa main method Some of the attributes ofConcert are o Name o Capacity o Number of Tickets Sold By Phone o Number of Tickets Sold At the Venue o The price of a ticket by phone o The price of a ticket at the venue Create the following Constructors o Default sets everything to default values o One that has the parameters (in this order) Band name Capacity Price by phone Price at the venue o One that has parameters (in this order) Name Capacity Number of Tickets Sold By Phone Number of Tickets Sold At the Venue The price of a ticket by phone The price of a ticket at the venue Accessors and Mutators for each variable o MAKE SURE THE MUTATORS CHECK FOR VALID VALUES! Create the following Methods o Total NumberOfTicketsSold No parameters Retums the value of the phone tickets plus the venue tickets o TicketsRemaining No parameters Returns the value of the capacity minus the total number oftickets sold o Buy Tickets/AtVenue 1 parameter that comes to the number of tickets being bought sponds returns nothing o Buy Tickets ByPhone l parameter that comesponds to the number of tickets being bought returns nothing o TotalSales No parameters Returns the value of the ticket at the venue times the number of tickets sold at the venue, plus the tickets by phone times the price of a phone ticketExplanation / Answer
Java Class: without main method (as per requested):
class Concert{
private String name; //variable for band name
private int capacity; //variable for capacity
private int byPhone; //variable for no of tickets sold by phone
private int atVenue; //variable for no of tickets sold at vnue
private int phonePrice; //variable for phone price of ticket
private int venuePrice; //variable for venue price of ticket
// default constructor with default values
public Concert(){
this.setName("default name");
this.setCapacity(100);
this.setByPhone(0);
this.setAtVenue(0);
this.setPhonePrice(10);
this.setVenuePrice(8);
}
// constructor with parameters
public Concert(String bandName, int capacity, int phonePrice, int venuePrice){
this.setName(bandName);
this.setCapacity(capacity);
this.setPhonePrice(phonePrice);
this.setVenuePrice(venuePrice);
}
// constructor with parameters
public Concert(String bandName, int capacity, int byPhone, int atVenue, int phonePrice, int venuePrice){
this.setName(bandName);
this.setCapacity(capacity);
this.setByPhone(byPhone);
this.setAtVenue(atVenue);
this.setPhonePrice(phonePrice);
this.setVenuePrice(venuePrice);
}
// setter & getter methods for variables
public void setName(String name){
this.name = name;
}
public String getName(){
return name;
}
public void setCapacity(int capacity){
this.capacity = capacity;
}
public int getCapacity(){
return capacity;
}
public void setByPhone(int byPhone){
this.byPhone = byPhone;
}
public int getByPhone(){
return byPhone;
}
public void setAtVenue(int atVenue){
this.atVenue = atVenue;
}
public int getAtVenue(){
return atVenue;
}
public void setPhonePrice(int phonePrice){
this.phonePrice = phonePrice;
}
public int getPhonePrice(){
return phonePrice;
}
public void setVenuePrice(int venuePrice){
this.venuePrice = venuePrice;
}
public int getVenuePrice(){
return venuePrice;
}
// method to trace the no of tickets sold
public int totalNumberOfTicketsSold(){
return getByPhone() + getAtVenue();
}
// method to track tickets remaining to sell
public int ticketsRemaining(){
return getCapacity() - totalNumberOfTicketsSold();
}
// method to track no of tickets bought at venue
public void buyTicketsAtVenue(int noOfTickets){
this.setAtVenue(noOfTickets);
}
//method to track no of tickets bought by phone
public void buyTicketsByPhone(int noOfTickets){
this.setByPhone(noOfTickets);
}
//method to calculate the sale of tickets both by phone & at venue
public int totalSales(){
return (getByPhone() * getPhonePrice() )+ ( getAtVenue() * getVenuePrice());
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.