Question

In: Computer Science

Java. Part 1 of 4 - Amusement Park Programming Project Requirements: Use the Java selection constructs...

Java.

Part 1 of 4 - Amusement Park Programming Project

Requirements:

  1. Use the Java selection constructs (if and if else).
  2. Use the Java iteration constructs (while, do, for).
  3. Use Boolean variables and expressions to control iterations.
  4. Proper error handling.

Class:

Ticket – models admission tickets.

Instance Fields:

  1. number : long – identify the unique ticket.
  2. category : String – store the category of the ticket.
  3. holder : String – store the name of the person who purchased the ticket.
  4. date : Date – store the admission date for the ticket.
  5. price : double – store the price of the ticket.
  6. status : Boolean – indicate if the ticket has been purchased (or is reserved)

Constructors and Methods:

  1. Ticket (String, String, Date, double, boolean) – Parameterized constructor that initializes the attributes of a ticket.
  2. setPrice(double) – to change the price of a ticket.
  3. changePurchaseStatus(boolean) – to change the purchase status of the ticket.
  4. getNumber() : long – Accessor method for instance field.
  5. getCategory() : String – Accessor method for instance field.
  6. getHolder() : String – Accessor method for instance field.
  7. getDate() : String – Accessor method for instance field.
  8. getPrice() : double – Accessor method for instance field.
  9. toString() : String – to return a neatly formatted string that contains all the information stored in the instance fields.

Solutions

Expert Solution

import java.text.SimpleDateFormat;
import java.util.Date;

public class Ticket {
   private long number;
   private String category;
   private String holder;
   private Date date;
   private double price;
   private boolean status;
   public Ticket(){
      
   }
   public Ticket(String category,String holder,Date date,double price,boolean status){
       this.category=category;
       this.holder=holder;
       this.date=date;
       this.price=price;
       this.status=status;
   }
   public void setPrice(double price){
       this.price=price;
   }
   public void changePurchaseStatus(boolean status){
       this.status=status;
   }

   public long getNumber() {
       return number;
   }
   public String getCategory() {
       return category;
   }
   public String getHolder() {
       return holder;
   }
   public Date getDate() {
       return date;
   }
   public double getPrice() {
       return price;
   }
   public String toString(){
   SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
       return "Number: "+this.number+"\nCategory: "+this.category+"\nHolder: "+this.holder+""
               + "\nDate: "+formatter.format(this.date)+"\nPrice: "+this.price+"\nStatus: "+this.status;
   }

}
  


Related Solutions

The assignment: C++ program or Java You need to use the following programming constructs/data structures on...
The assignment: C++ program or Java You need to use the following programming constructs/data structures on this assignment. 1. A structure named student which contains:   a. int ID; student id; b. last name; // as either array of char or a string c. double GPA;    2. An input file containing the information of at least 10 students. 3. An array of struct: read the student information from the input file into the array. 4. A stack: you can use the...
Java programming. *******I Need complete the following requirements in this project: 1/ Remove the applyRandomBonus method...
Java programming. *******I Need complete the following requirements in this project: 1/ Remove the applyRandomBonus method from the test class 2/ Create a File, Printwriter for an output file yourlastnameErrorLog.txt 3/ Set your maximum array size for accounts to 10 4/ Catch InputMismatch and ArrayIndexOutOfBounds exceptions when reading data from the file: a. Skip any lines that cause an exception b. Write information about the exception to the log file, yourlastnameError.txt c. Include exception type and line number in exception...
Write any java programming to meet the following requirements. Your project must meet the following requirements:...
Write any java programming to meet the following requirements. Your project must meet the following requirements: 1. Specify input specification      Design input 2. Specify Output Specification     Design Output 3. The class must include set methods and get methods ( with or without parameters both) 4. Must include Array structure 5. Must include Input or Output Files or both 6. Demonstrate your knowledge of an Applet
Programming Project #1: Manage Simple Expenses Objectives: • Use basic C++ constructs: if, switch, repetition (looping)...
Programming Project #1: Manage Simple Expenses Objectives: • Use basic C++ constructs: if, switch, repetition (looping) and functions • Perform simple data type and string object manipulations • Solve problem, design solution and implement using C++ Description: Write a menu-driven program named “ManageSimpleExpenses” that provides the following options: 1. Earn 2. Spend 3. Show logs 4. Exit Basically, the program allows the user to enter earning or spending amounts and keep track of the current balance. It also print out...
At a particular amusement park, most of the live characters have height requirements of a minimum...
At a particular amusement park, most of the live characters have height requirements of a minimum of 57 in. and a maximum of 63 in. A survey found that​ women's heights are normally distributed with a mean of 62.4 in. and a standard deviation of 3.6 in. The survey also found that​ men's heights are normally distributed with a mean of 68.3 in. and a standard deviation of 3.6 in. Part 1: Find the percentage of men meeting the height...
There is a new amusement park under construction in town and the manager of the project...
There is a new amusement park under construction in town and the manager of the project has hired you to design a "Zero-Gravity" room. (a) Based on your knowledge of nature of electric charge and electric forces, how will you design such a facility? Comment on components of the room, and explain how it will work for walk in customers? What would be the safety concerns and measures? (b) Assume that your design has been approved and facility has been...
Consider a project to build an amusement park. What are some of theresource constraints that...
Consider a project to build an amusement park. What are some of the resource constraints that would make this project challenging? What could you do, as a project manager, to help manage the constraints and project scheduling?
A new roller coaster at an amusement park requires individuals to be at least​ 4' 8"...
A new roller coaster at an amusement park requires individuals to be at least​ 4' 8" ​(56 inches) tall to ride. It is estimated that the heights of​ 10-year-old boys are normally distributed with mu equals μ=55.0 inches and sigma equals σ=4 inches. a. What proportion of​ 10-year-old boys is tall enough to ride the​ coaster? b. A smaller coaster has a height requirement of 50 inches to ride. What proportion of​ 10-year-old boys is tall enough to ride this​...
Java Project Requirements: 1.Write a Java program that plays a word game with a user. The...
Java Project Requirements: 1.Write a Java program that plays a word game with a user. The program asks the user questions and then creates a paragraph using the user’s answers. 2.The program must perform the following: a.Uses a Scanner object to ask the user: (The program asks for no other information) i.Full Name (First and Last name only) - stores this Full Name in one String object variable. ii.Age – must be read in as an int. iii.Profession or expected...
JAVA programming - please answer all prompts as apart of 1 java assignment. Part A Create...
JAVA programming - please answer all prompts as apart of 1 java assignment. Part A Create a java class InventoryItem which has a String description a double price an int howMany Provide a copy constructor in addition to other constructors. The copy constructor should copy description and price but not howMany, which defaults to 1 instead. In all inheriting classes, also provide copy constructors which chain to this one. Write a clone method that uses the copy constructor to create...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT