Objective Write a class that keeps track of concert promotio
Solution
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());
}
}

