Create a system to track the number of tickets available

Assignment Help JAVA Programming
Reference no: EM131667286

Java Programming Assignment: Concert Ticket System

Objective

Demonstrate knowledge of using while and for loops.

Overview

You are creating a system to track the number of tickets available and allow the user to buy tickets. There are two type of tickets - VIP tickets and General Floor tickets.

Procedure

Open BlueJ and create a new project called Assignment05-userName, where username is your USC username (your email address without the @usc.edu) . Get the starter code from Blackboard. Read over and understand the code that already exists.

ConsoleMenu.java (modified from in class CoffeeShop code)

Update the getUserChoice() method in the ConsoleMenu class to make the method loop in order to only allow the user to enter the numbers 1 through numOptions

TicketSystem.java

This skeleton class does some of the setup for the ticket system program; it is up to you to complete this code.

Instance Variables

There are 5 instance variables in this class. You should not create any more.

private Scanner input; // Used to get input from the user

private ConsoleMenu menu; // Used to display a menu and get input from the user private String concertName; // Name of the concert the user is buying tickets for private String venueName; //Name of the venue for the concert

private final int TOTAL_ROWS; //total number of rows in the venue (set in the constructor) private final int VIP_ROWS; // number of VIP rows in the venue (set in the constructor) private int vipSeatsSold; // Needs to increase when the user buys VIP tickets

private int generalSeatsSold; // Needs to increase when the user buys General Floor tickets

Class Variables

There are 3 static constants that you will also use in your program, for setting up the menu and for defining a standard number of seats per row.

Constructors

One constructor is provided for you, it is a version that takes 4 input variables and sets up the corresponding instance variables accordingly. In addition, the other 4 instance variables are initialized in this version of the constructor. Make sure you understand it.

Overload the constructor to allow a user of the system of the Ticket System to just provide a concert & venue name. Also provide a default constructor and set up the concert as "The Killers" playing at the "Staples Center". Do not simply copy and paste the code; you must use the programming construct this() as a method that allows one version of the constructors to call another. Each of the constructors that you provide should have only one statement.

Public Method

The heart of your program is the run method. This method will control how the ticket system runs and will call helper methods to perform tasks.

public void run()

• Print a welcome message that includes the eventName and the venue name. (Could be a method or code within run)

• Print the menu and get input from the user. Use a while or do-while loop to do this until the user enters the option 4 (to EXIT). Don't use a literal "magic "number 4; use the appropriate constant.

o To print the menu, use the ConsoleMenu object.
o Get the menu option by using the ConsoleMenu object.
o Use a switch statement to call the corresponding helper method. For 1, call the printSeats method. For 2, call the buyGeneralTickets method. For 3, call the buyVipTickets method.

• Print a closing message that includes the eventName. (Could be a method or code within run)

Private Methods

Create various helper methods to perform tasks. The following private methods are required. Create as many local variables in the methods as you need. You should not create any more instance variables. You may create other helper methods if you want.

private int vipSeatsAvailable()

• Calculate and return the number of VIP seats available. Use the number of VIP rows, and the number of seats per row to know the number of seats. Use the vipSeatsSold instance variable to figure out how many are available at any point during the program's run time.
private int generalSeatsAvailable()

• Calculate and return the number of Regular concert seats available. Use the total number of row, the number of VIP rows, and the number of seats per row to know the number of general seats in total. Use the generalSeatsSold instance variable to figure out how many are available at any point during the program's run time.

private void printSeats()

• Use nested for loops (Week 7 lecture) to print a diagram of the seats. Print a (V) for VIP seats and a (G) for General Floor seats. Use the TOTAL_ROWS, SEATS_PER_ROW, and VIP_ROWS constants.

• Follow the map with a print out of the number of VIP seats available and the number of General Floor seats available. Use the vipSeatsAvailable and generalSeatsAvailable private helper methods.

• BONUS: print an "x" instead of the (V) or (G) to indicate a seat that is sold.

private void printDashes(int num)

• Use a for loop to print the number of dashes (-) based on the parameter num. (See the example ticket below to see the what printed dashes does; if printDashes(50) is called, then the program loops to print 50 dashes in one row.)
private void printTicket(boolean isVip, int ticketsPurchased)

• Call the printDashes method twice to print two lines of 40 dashes.

• Print the concert name, followed by the venue name. (Include a tab character to indent the text)

• If the isVip parameter is true, then print "VIP Tickets". In the next line, print the starting and ending seat numbers. Use the vipSeatsSold instance variable and the ticketsPurchased parameter to calculate the seat numbers. (Note: printing seat numbers can be a little tricky. You will need to do a little problem-solving to figure out what seat numbers are sold. For example, if 4 vip seat are already sold, and somebody purchases 3 seats, then their seat numbers should be 5-7)

• If the isVip parameter is false, then print "\tGeneral Floor Tickets". In the next line, print the starting and ending seat numbers. Use the generalSeatsSoldinstance variable and the ticketsPurchased parameter to calculate them. (Similar thought process for seat numbers)

• Call the printDashes twice to print two lines of 40 dashes.

private void buyGeneralTickets()

• If there are no general seats available, then print an appropriate message.

• If there are general seats available, then tell the user how many seats are available and ask them how many seats they want to buy. Get their input.

o If the user enters a number less than 1, then print an appropriate message.
o If the user enters a number greater than the seats available, then print an appropriate message.
o If the user enters a valid number, then call the appropriate code to update ("sell") that number of general seats and call the printTicket method with the appropriate parameters.

private void buyVipTickets()

• If there are no vip seats available, then print an appropriate message.

• If there are vip seats available, then tell the user how many seats are available and ask them how many seats they want to buy. Get their input.

o If the user enters a number less than 1, then print an appropriate message.

o If the user enters a number greater than the seats available, then print an appropriate message.

o If the user enters a valid number, then call the appropriate code to update ("sell") that number of vip seats and call the printTicket method with the appropriate parameters.

You may create other helper methods if you want.

Documentation

Use Java doc comments before all methods to ensure good documentation of your code.

Code In Action (Sample Console Output)

Use the previous and following screen shots to see test input and the corresponding results.

Attachment:- Java-Assignment.rar

Reference no: EM131667286

Questions Cloud

Demonstrate strong leadership skills : "Please submit a brief statement of 300 words outlining how you demonstrate strong leadership skills."
Implementing state of the art information systems : Implementing State of the art Information Systems in a New Hospital. Imagine a new hospital is about to be built, for example the new Royal Adelaide hospital.
The title of a scholarly journal : The title of a scholarly journal (periodical) should appear
Discuss about the personal aspects of employees lives : Should criminal justice managers be concerned with the personal aspects of employees lives?
Create a system to track the number of tickets available : Create a system to track number of tickets available and allow user to buy tickets. There are two type of tickets - VIP tickets and General Floor tickets.
Change the structure of employee compensation : You are the human resources manager for a famous retailer and are trying to convince the president of the company to change the structure of employee.
Address risks for data security from the viewpoint : Case Study in support of a significant technology decision that is to be taken by a fictional company called Aztek that operates in the Australian Financial
Develop a sentence outline for your paper : Develop a 2-3 page sentence outline for your paper, and complete an annotated bibliography.
How would you use data from the foreign exchange market : How would you use data from the foreign exchange market to decide between these two hypotheses?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Determine the best way to gather business rules

You have been hired by Happy Health to determine the best way to gather business rules for a new phone system.

  Write a program that displays the squares

Using a for loop, write a program that displays the squares of all integers greater than 0 and less than or equal to a given number n. Use the c ++ programming language to write the code.

  Implement one class called parking meter

Implement one class called parking meter, that is a simple model of a coin operated parking meter

  Give the syntax of do while statement

Please complete the following short answer questions with code snippets as well as paragraphical responses. This assignment should not be an exercise in copy and paste, but an assessment of your comprehension and evaluation of the course materials..

  Make a program in java language with classes

Make a program, in JAVA language with classes, that simulates health attending in one business day, according to the information just given.

  Write a program displaying a text file that is in a text are

Write a program displaying a text file that is in a text area. The user enteres a file name in a text field and clicks the view button; the file is then displayed in the text area. Do not use BufferedInputStream.

  1write a program that uses joptionpanes to perform the

1.write a program that uses joptionpanes to perform the following stepsmiddotfirst display a welcome message to your

  Study the code and implement the operator overloading

The Table Q3 on the next page is the code of a class named Circle. Study the code and implement the operator overloading for these relational operators ( , >=) for the Circle class. Then, write a test program that creates two instances of the Circle ..

  Add event handling to the button find out the value the

make a windows program in java that has a labeled text field for the price of a meal. there are different discounts for

  Display student details and classes in applet

Display student details and classes they have enrolled in Applet. The Applet should have following features. Update and View.

  Demonstrate how the quicksort algorithm behaves

Demonstrate how the quicksort algorithm behaves. You will be implementing quicksort, but in a way that allows the program's user to visually observe how the algorithm proceeds by watching animated colored bars.

  Multiple choice java programming questions

Determine which of the following may be a violation of information hiding if inserted for the comment above?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd