Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1: demonstrate inheritance of classes (30 points) You are creating a system for the traffic portion of a police department in a new source

Part 1: demonstrate inheritance of classes (30 points) You are creating a system for the traffic portion of a police department in a new source package named traffic. It will one day be placed in new handheld computers so the officers on traffic duty can print these tickets from handheld computers. Java is a perfect language to create this kind of application as we learned earlier in the course. There are several types of Ticket though so this is a perfect one to demonstrate inheritance with. Every Ticket has a Tag (license plate number), Make, Model, and Color. Each Ticket also has a special version..these are the inheriting classes.... A TimeExpiredTicket is a Ticket for a car parked too long in a timed zone or when a parking meter has no time left and shows the expired flag while the car is there. This type of ticket has a $50 charge. A HandicappedTicket is a Ticket for a car parked in a handicapped zone with no handicapped permit on it. This type of ticket has a $100 charge. A FireLaneTicket is a Ticket for a car parked in fire lane or beside a fire hydrant. This type of ticket has a $150 charge. Make the ticket super class, and the three subclasses inheriting from it. Then write a class with main() to test your new classes by making at least one object of each of the three types of tickets (expired, handicapped, and fire lane) and later report their information stored in them to the user. Note: You can put the charge in the a message being printed or as a variable holding the value. Its up to you. You do have to have the tag, make, model, and color along with their gets and sets only in the ticket superclass. You have to demonstrate inheritance here by inheriting from the base class which is holding these values.

Part2: demonstrate Polymorphism of Classes (30 points) Make a copy of the part 1 to a new source package named abstarcttraffic and make the following changes: Your system is going to have to have an array of the different tickets. They are going to be printed and processed in order. This means you have to use polymorphism to do this because they are different types of tickets. Make sure Ticket is now abstract. There are no general tickets. They must all be of one of the subclass types. Make an abstract method called printTicket() in the base Ticket class. Make a method called printTicket() in each of the subclasses that prints out the tag, make, model, color, and charge information along with a message for what kind of ticket it is. In the class testing the classes you created....make an array of tickets including at least one of the three types of tickets (expired, handicapped, and fire lane). Then use a loop to process the whole array and call printTicket() to polymorphically print them all out.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions

Question

Graph the first-octant portion of each plane. x = 5

Answered: 1 week ago

Question

What are the three most common sources of equity funding?

Answered: 1 week ago