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

Java Part 2 of 4 - Amusement Park Programming Project MUST BE COMPATIBLE WITH PART 1...
Java Part 2 of 4 - Amusement Park Programming Project MUST BE COMPATIBLE WITH PART 1 https://www.chegg.com/homework-help/questions-and-answers/java-part-1-4-amusement-park-programming-project-requirements-use-java-selection-construct-q40170145?trackid=ERIFssNL Requirements: Use the Java selection constructs (if and if else). Use the Java iteration constructs (while, do, for). Use Boolean variables and expressions to control iterations. Proper error handling. Class: Merchandise – models merchandise available in the gift shop such as t-shirts, sweatshirts, and stuffed animals. Instance Fields: id : long – to identify the specific merchandise item. category : String – to...
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?
4 Implement a Java program that meets the following requirements • You can use the Java...
4 Implement a Java program that meets the following requirements • You can use the Java standard sequence data structure API types for sets, lists, stack,queue and priority queue as needed. All are available in the java.util package, which you will want to import in your program. 1. Argue in code comments which data structure, stack or queue, you will use to implement this method. Implement a method which creates some String objects as food orders for a small restaurant,...
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​...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT