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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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