Using Dr. Java Objective: Write a class that keeps track of concert promotion in
ID: 3800273 • Letter: U
Question
Using Dr. Java
Objective:
Write a class that keeps track of concert promotion information
First down load the driver and put it in your project
Notice that this has all of the dialog outputs and user inputs already written
You are writing the backend not he front end
Write a class file called Concert that DOES NOT HAVE a main method
Some of the attributes of Concert are
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
Create the following Constructors
Default – sets everything to default values
One that has the parameters (in this order)
Band name
Capacity
Price by phone
Price at the venue
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
MAKE SURE THE MUTATORS CHECK FOR VALID VALUES!
Create the following Methods
TotalNumberOfTicketsSold
No parameters
Returns the value of the phone tickets plus the venue tickets
TicketsRemaining
No parameters
Returns the value of the capacity minus the total number of tickets sold
BuyTicketsAtVenue
1 parameter that corresponds to the number of tickets being bought
returns nothing
BuyTicketsByPhone
1 parameter that corresponds to the number of tickets being bought
returns nothing
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 ticket
Example Dialog:
Welcome to the Concert Promotion tool!
Currently the concert featuring the band No name yet
Has sold 0 tickets by phone
Has sold 0 tickets at the venue
And has grossed $0.0
What would you like to do?
Enter 1: To change name
Enter 2: To change ticket by phone price
Enter 3: To change ticket at venue price
Enter 4: To add tickets by phone
Enter 5: To add tickets at the venue
Enter 6: To find out how many tickets are remaining
Enter 7: To find out how many total tickets have been sold
Enter 8: To change the venue's capacity
Enter 9: To start a new concert
Enter 0: To Quit
1
Enter the name of the band
Bob's Band
Currently the concert featuring the band Bob's Band
Has sold 0 tickets by phone
Has sold 0 tickets at the venue
And has grossed $0.0
What would you like to do?
Enter 1: To change name
Enter 2: To change ticket by phone price
Enter 3: To change ticket at venue price
Enter 4: To add tickets by phone
Enter 5: To add tickets at the venue
Enter 6: To find out how many tickets are remaining
Enter 7: To find out how many total tickets have been sold
Enter 8: To change the venue's capacity
Enter 9: To start a new concert
Enter 0: To Quit
8
Enter the new capacity
500
Currently the concert featuring the band Bob's Band
Has sold 0 tickets by phone
Has sold 0 tickets at the venue
And has grossed $0.0
What would you like to do?
Enter 1: To change name
Enter 2: To change ticket by phone price
Enter 3: To change ticket at venue price
Enter 4: To add tickets by phone
Enter 5: To add tickets at the venue
Enter 6: To find out how many tickets are remaining
Enter 7: To find out how many total tickets have been sold
Enter 8: To change the venue's capacity
Enter 9: To start a new concert
Enter 0: To Quit
2
Enter the new price by phone
5
Currently the concert featuring the band Bob's Band
Has sold 0 tickets by phone
Has sold 0 tickets at the venue
And has grossed $0.0
What would you like to do?
Enter 1: To change name
Enter 2: To change ticket by phone price
Enter 3: To change ticket at venue price
Enter 4: To add tickets by phone
Enter 5: To add tickets at the venue
Enter 6: To find out how many tickets are remaining
Enter 7: To find out how many total tickets have been sold
Enter 8: To change the venue's capacity
Enter 9: To start a new concert
Enter 0: To Quit
3
Enter the new price at the venue
10
Currently the concert featuring the band Bob's Band
Has sold 0 tickets by phone
Has sold 0 tickets at the venue
And has grossed $0.0
What would you like to do?
Enter 1: To change name
Enter 2: To change ticket by phone price
Enter 3: To change ticket at venue price
Enter 4: To add tickets by phone
Enter 5: To add tickets at the venue
Enter 6: To find out how many tickets are remaining
Enter 7: To find out how many total tickets have been sold
Enter 8: To change the venue's capacity
Enter 9: To start a new concert
Enter 0: To Quit
4
Enter a number of tickets to add by phone
200
Currently the concert featuring the band Bob's Band
Has sold 200 tickets by phone
Has sold 0 tickets at the venue
And has grossed $1000.0
What would you like to do?
Enter 1: To change name
Enter 2: To change ticket by phone price
Enter 3: To change ticket at venue price
Enter 4: To add tickets by phone
Enter 5: To add tickets at the venue
Enter 6: To find out how many tickets are remaining
Enter 7: To find out how many total tickets have been sold
Enter 8: To change the venue's capacity
Enter 9: To start a new concert
Enter 0: To Quit
5
Enter a number of tickets to add at the venue
200
Currently the concert featuring the band Bob's Band
Has sold 200 tickets by phone
Has sold 200 tickets at the venue
And has grossed $3000.0
What would you like to do?
Enter 1: To change name
Enter 2: To change ticket by phone price
Enter 3: To change ticket at venue price
Enter 4: To add tickets by phone
Enter 5: To add tickets at the venue
Enter 6: To find out how many tickets are remaining
Enter 7: To find out how many total tickets have been sold
Enter 8: To change the venue's capacity
Enter 9: To start a new concert
Enter 0: To Quit
4
Enter a number of tickets to add by phone
1000
The concert is sold out!
Currently the concert featuring the band Bob's Band
Has sold 200 tickets by phone
Has sold 200 tickets at the venue
And has grossed $3000.0
What would you like to do?
Enter 1: To change name
Enter 2: To change ticket by phone price
Enter 3: To change ticket at venue price
Enter 4: To add tickets by phone
Enter 5: To add tickets at the venue
Enter 6: To find out how many tickets are remaining
Enter 7: To find out how many total tickets have been sold
Enter 8: To change the venue's capacity
Enter 9: To start a new concert
Enter 0: To Quit
0
//driver
Explanation / Answer
Hi, its really nice to help you
As u above stated you dont required driver class its already provided
i have created a backend class Concert and integratedd with Driver Class.
Please find below the code and output attached
Concert.java
public class Concert {
//required fields
private String name;
private int capacity;
private int numberOfTicketsSoldByPhone;
private int numberOfTicketsSoldAtVenue;
private double priceOfTicketByPhone;
private double priceOfTicketAtVenue;
//Dault constructor
public Concert(){
}
//parameterized constructor 1
public Concert(String bandName,int capacity,double priceAtPhone,double priceAtVenue){
this.name = bandName;
this.capacity = capacity;
this.priceOfTicketByPhone=priceAtPhone;
this.priceOfTicketAtVenue=priceAtVenue;
}
//parameterized constructor 2
public Concert(int ticketSoldByPhone, int ticketSoldAtVenue,double priceAtPhone, double priceAtVenue){
this.numberOfTicketsSoldByPhone = ticketSoldByPhone;
this.numberOfTicketsSoldAtVenue=ticketSoldAtVenue;
this.priceOfTicketByPhone=priceAtPhone;
this.priceOfTicketAtVenue=priceAtVenue;
}
public String getName() {
return name;
}
//I believe Band name may int only or albhabetical or both hence doesnt
//require validation
public void setName(String bandName) {
this.name = bandName;
}
public int getCapacity() {
return capacity;
}
//have applied simple validation for checking data type, however
//your scanner object in Driver class is taking only data type specific input only
//like nextInt(), nextDoble() if you provide any diff data type it will raise and runtime exception
public void setCapacity(int capacity) {
if(capacity==(int)capacity){
this.capacity = capacity;}
else{
System.out.println("No valid input");
}
}
public int getNumberOfTicketsSoldByPhone() {
return numberOfTicketsSoldByPhone;
}
public void setNumberOfTicketsSoldByPhone(int ticketSoldByPhone) {
if(ticketSoldByPhone == (int)ticketSoldByPhone){
this.numberOfTicketsSoldByPhone=this.numberOfTicketsSoldByPhone+ticketSoldByPhone;
}
}
public int getNumberOfTicketsSoldAtVenue() {
return numberOfTicketsSoldAtVenue;
}
public void setNumberOfTicketsSoldAtVenue(int ticketSoldAtVenue) {
if(ticketSoldAtVenue==(int)ticketSoldAtVenue){
numberOfTicketsSoldAtVenue = numberOfTicketsSoldAtVenue+ticketSoldAtVenue;
}
else{
System.out.println("Not valid input");
}
}
public double getThe_price_of_a_ticket_by_phone() {
return priceOfTicketByPhone;
}
public void setPriceByPhone(double phoneTicketPrice) {
if(phoneTicketPrice==(double)phoneTicketPrice){
priceOfTicketByPhone = phoneTicketPrice;
}
else{
System.out.println("Not valid input");
}
}
public double getThe_price_of_a_ticket_at_the_venue() {
return priceOfTicketAtVenue;
}
public void setPriceAtVenue(double venueAtPrice) {
if(venueAtPrice==(double)venueAtPrice){
priceOfTicketAtVenue = venueAtPrice;
}
else{
System.out.println("Not valid input");
}
}
public int TotalNumberOfTicketsSold(){
return numberOfTicketsSoldAtVenue+numberOfTicketsSoldByPhone;
}
public int TicketsRemaining(){
return capacity-TotalNumberOfTicketsSold();
}
public void BuyTicketsAtVenue(int no){
this.numberOfTicketsSoldAtVenue=this.numberOfTicketsSoldAtVenue+no;
}
public void BuyTicketsByPhone(int no){
this.numberOfTicketsSoldByPhone=this.numberOfTicketsSoldByPhone+no;
}
public double TotalSales(){
double totalSalebyPhone = numberOfTicketsSoldByPhone*priceOfTicketByPhone;
double totalSaleAtVenue = numberOfTicketsSoldAtVenue*priceOfTicketAtVenue;
return totalSaleAtVenue+totalSalebyPhone;
}
}
//Driver Class same as u posted above nothing change
import java.util.*;
public class ConcertPromotor {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner keyboard = new Scanner(System.in);
Concert concert = new Concert();
System.out.println("Welcome to the Concert Promotion tool!");
String input = "";
while(input.equalsIgnoreCase("quit")!= true)
{
System.out.println("Currently the concert featuring the band "+concert.getName());
System.out.println("Has sold "+concert.getNumberOfTicketsSoldByPhone()+" tickets by phone");
System.out.println("Has sold "+concert.getNumberOfTicketsSoldAtVenue()+" tickets at the venue");
System.out.println("And has grossed $"+concert.TotalSales());
System.out.println("What would you like to do? " +
"Enter 1: To change name " +
"Enter 2: To change ticket by phone price " +
"Enter 3: To change ticket at venue price " +
"Enter 4: To add tickets by phone " +
"Enter 5: To add tickets at the venue " +
"Enter 6: To find out how many tickets are remaining " +
"Enter 7: To find out how many total tickets have been sold " +
"Enter 8: To change the venue's capacity " +
"Enter 9: To start a new concert " +
"Enter 0: To Quit ");
int choice = keyboard.nextInt();
keyboard.nextLine();
switch(choice)
{
case 1:
System.out.println("Enter the name of the band");
concert.setName(keyboard.nextLine());
break;
case 2:
System.out.println("Enter the new price by phone");
concert.setPriceByPhone(keyboard.nextDouble());
break;
case 3:
System.out.println("Enter the new price at the venue");
concert.setPriceAtVenue(keyboard.nextDouble());
break;
case 4:
System.out.println("Enter a number of tickets to add by phone");
concert.BuyTicketsByPhone(keyboard.nextInt());
break;
case 5:
System.out.println("Enter a number of tickets to add at the venue");
concert.BuyTicketsAtVenue(keyboard.nextInt());
break;
case 6:
System.out.println("The number of tickets remaining are "+concert.TicketsRemaining());
break;
case 7:
System.out.println("The number of tickets sold are "+concert.TotalNumberOfTicketsSold());
break;
case 8:
System.out.println("Enter the new capacity");
concert.setCapacity(keyboard.nextInt());
break;
case 9:
System.out.println("Starting a new concert");
System.out.println("Enter the name of the band");
String name = keyboard.nextLine();
System.out.println("Enter the capacity of the venue");
int capacity = keyboard.nextInt();
System.out.println("Enter the price by phone");
double priceByPhone = keyboard.nextDouble();
System.out.println("Enter the price at the venue");
double priceAtVenue = keyboard.nextDouble();
concert = new Concert(name,capacity,priceByPhone,priceAtVenue);
break;
case 0:
input = "quit";
break;
}
}
}
}
OUTPUT:
Welcome to the Concert Promotion tool!
Currently the concert featuring the band null
Has sold 0 tickets by phone
Has sold 0 tickets at the venue
And has grossed $0.0
What would you like to do?
Enter 1: To change name
Enter 2: To change ticket by phone price
Enter 3: To change ticket at venue price
Enter 4: To add tickets by phone
Enter 5: To add tickets at the venue
Enter 6: To find out how many tickets are remaining
Enter 7: To find out how many total tickets have been sold
Enter 8: To change the venue's capacity
Enter 9: To start a new concert
Enter 0: To Quit
1
Enter the name of the band
John
Currently the concert featuring the band John
Has sold 0 tickets by phone
Has sold 0 tickets at the venue
And has grossed $0.0
What would you like to do?
Enter 1: To change name
Enter 2: To change ticket by phone price
Enter 3: To change ticket at venue price
Enter 4: To add tickets by phone
Enter 5: To add tickets at the venue
Enter 6: To find out how many tickets are remaining
Enter 7: To find out how many total tickets have been sold
Enter 8: To change the venue's capacity
Enter 9: To start a new concert
Enter 0: To Quit
8
Enter the new capacity
100
Currently the concert featuring the band John
Has sold 0 tickets by phone
Has sold 0 tickets at the venue
And has grossed $0.0
What would you like to do?
Enter 1: To change name
Enter 2: To change ticket by phone price
Enter 3: To change ticket at venue price
Enter 4: To add tickets by phone
Enter 5: To add tickets at the venue
Enter 6: To find out how many tickets are remaining
Enter 7: To find out how many total tickets have been sold
Enter 8: To change the venue's capacity
Enter 9: To start a new concert
Enter 0: To Quit
2
Enter the new price by phone
30
Currently the concert featuring the band John
Has sold 0 tickets by phone
Has sold 0 tickets at the venue
And has grossed $0.0
What would you like to do?
Enter 1: To change name
Enter 2: To change ticket by phone price
Enter 3: To change ticket at venue price
Enter 4: To add tickets by phone
Enter 5: To add tickets at the venue
Enter 6: To find out how many tickets are remaining
Enter 7: To find out how many total tickets have been sold
Enter 8: To change the venue's capacity
Enter 9: To start a new concert
Enter 0: To Quit
3
Enter the new price at the venue
50
Currently the concert featuring the band John
Has sold 0 tickets by phone
Has sold 0 tickets at the venue
And has grossed $0.0
What would you like to do?
Enter 1: To change name
Enter 2: To change ticket by phone price
Enter 3: To change ticket at venue price
Enter 4: To add tickets by phone
Enter 5: To add tickets at the venue
Enter 6: To find out how many tickets are remaining
Enter 7: To find out how many total tickets have been sold
Enter 8: To change the venue's capacity
Enter 9: To start a new concert
Enter 0: To Quit
4
Enter a number of tickets to add by phone
33
Currently the concert featuring the band John
Has sold 33 tickets by phone
Has sold 0 tickets at the venue
And has grossed $990.0
What would you like to do?
Enter 1: To change name
Enter 2: To change ticket by phone price
Enter 3: To change ticket at venue price
Enter 4: To add tickets by phone
Enter 5: To add tickets at the venue
Enter 6: To find out how many tickets are remaining
Enter 7: To find out how many total tickets have been sold
Enter 8: To change the venue's capacity
Enter 9: To start a new concert
Enter 0: To Quit
5
Enter a number of tickets to add at the venue
23
Currently the concert featuring the band John
Has sold 33 tickets by phone
Has sold 23 tickets at the venue
And has grossed $2140.0
What would you like to do?
Enter 1: To change name
Enter 2: To change ticket by phone price
Enter 3: To change ticket at venue price
Enter 4: To add tickets by phone
Enter 5: To add tickets at the venue
Enter 6: To find out how many tickets are remaining
Enter 7: To find out how many total tickets have been sold
Enter 8: To change the venue's capacity
Enter 9: To start a new concert
Enter 0: To Quit
6
The number of tickets remaining are 44
Currently the concert featuring the band John
Has sold 33 tickets by phone
Has sold 23 tickets at the venue
And has grossed $2140.0
What would you like to do?
Enter 1: To change name
Enter 2: To change ticket by phone price
Enter 3: To change ticket at venue price
Enter 4: To add tickets by phone
Enter 5: To add tickets at the venue
Enter 6: To find out how many tickets are remaining
Enter 7: To find out how many total tickets have been sold
Enter 8: To change the venue's capacity
Enter 9: To start a new concert
Enter 0: To Quit
7
The number of tickets sold are 56
Currently the concert featuring the band John
Has sold 33 tickets by phone
Has sold 23 tickets at the venue
And has grossed $2140.0
What would you like to do?
Enter 1: To change name
Enter 2: To change ticket by phone price
Enter 3: To change ticket at venue price
Enter 4: To add tickets by phone
Enter 5: To add tickets at the venue
Enter 6: To find out how many tickets are remaining
Enter 7: To find out how many total tickets have been sold
Enter 8: To change the venue's capacity
Enter 9: To start a new concert
Enter 0: To Quit
End of Output please do comment in case of any query.
Cheers:)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.