(求助)可以帮我看看这个吗
The TicketBooth ClassDefine a class called TicketBooth that defines the following attributes:
• moneyMade - a float indicating the amount of money received by
this booth so far
• availablePasses - an int indicating the number of passes that are
available at this booth
• availableTickets - an int indicating the number of tickets that are
available at this booth
Make the following two class constants:
• TICKET_PRICE - the price for each individual ticket ... set it to be $0.50.
• PASS_PRICE - the price for a ride pass ... set it to be $16.50.
Write a zero-parameter constructor as well as one that takes an initial # of passes that the booth has available. Also, write a constructor that takes an initial number of passes that the booth has available as well as the number of tickets that it has available. So … you will write 3 constructors altogether.
Lastly, write a toString() method that returns a string with the following format:
Ticket booth with 5 passes and 28 tickets
Making use of the two class constants above whenever possible, write these 2 methods:
• a sellPass()
() method that simulates the selling of a ride pass at this booth (Hint: Think of what happens in real life and then determine how the TicketBooth object changes as a result of this method. Make sure to handle the situation where there are no passes available).
• a sellTickets(int num) method that simulates the selling of the specified number of tickets at this booth. If there are not enough tickets to accommodate the requested amount then nothing happens, no selling takes place. (Hint: Think the same way as you did above).
Write a test program called TicketBoothTestProgram.java that creates two ticket booths ... the 1st one with 5 passes and 50 tickets available and the 2nd one with 1 pass and 10 tickets available. Your code should use the toString() method to display both of the booths to the console. Your program should then sell 2 passes from one of the booths and then simulate the situation in which that booth sells 5 tickets to someone, then "attempts to" sell 12 tickets to someone else and finally attempts to sell 3 more tickets one last time. For the other booth, repeat the process of attempting to sell 2 passes, followed by 5 tickets, 12 tickets and 3 tickets. Display the amount of money made from each of the booths at the end of your program and confirm that the values are correct. Also, re-display (using toString() the two booths to ensure that the number of tickets and passes remaining is correct).
Adjust your code so that it produces the following output exactly:
Here are the booths at the start:
Ticket booth with 5 passes and 50 tickets
Ticket booth with 1 passes and 10 tickets
Booth 1 has made $43.0
Booth 2 has made $20.5
Here are the booths at the end:
Ticket booth with 3 passes and 30 tickets
Ticket booth with 0 passes and 2 tickets