Create a Java class named Ticket that has the following state:a.costof the ticket as a doubleb.timeof purchase stored as a string similar to “1:10 pm” or “10:34 am”2.Implement encapsulation for these...

Create a Java class named Ticket that has the following state:a.costof the ticket as a doubleb.timeof purchase stored as a string similar to “1:10 pm” or “10:34 am”2.Implement encapsulation for these instance variablesa.Protect the instance variables from change outside an objectb.Create getters and setters for each variablec.Add logic that ensures values for each variable are set appropriately. For example, cost should not be a negative number. What else makes sense to validate before storing?3.Create a constructor that will be called when an object of type Ticket is createda.Constructor should set both cost and time to default values4.Create codereflecting actions that can be taken for Ticketa.isEveningTime returns true or false depending on whether the time is after 6pm but before midnightb.bulkDiscount that takes integer parameter n and returns discount for buying n ticketsi.10% discount for 5 to 9 ticketsii.20% discount for 10+ ticketsiii.No discount otherwise5.Create a Java class named MovieTicket that inherits from Ticket and has the following state:a.movieNameas a string6.Implement encapsulation for the new instance variablea.Protect the instance variables from change outside an objectb.Create getters and setters c.Add logic that ensures values for each variable are set appropriately. For example, name should not be an empty string7.Override bulkDiscount for MovieTicketa.10% discount for 10+ ticketsb.No discount otherwise8.Create a second tester program to test your Java code. a.Instantiate objects of both Ticket and MovieTicket typeb.Validate inheritance of constructor and instance variable values by printing for eachc.Execute bulkDiscount for Ticket and MovieTicket objects separately; validate the discount returned by printing returned value for each
Aug 29, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here