Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java, create a simple object model of a traffic infringements database system. It will allow you to start thinking about objects of less physical

In java, create a simple object model of a traffic infringements database system. It will allow you to start thinking about objects of less physical things. You should compile and run your application after each step.

a- Create a new project with a driver class named InfringementDriver that will contain the main method which will run our simple database system.

b- Write a class named Infringement that has the following attributes:

type, a string which describes the type of infringement, which can be any of the following items: parking illegally, speeding, unroadworthy vehicle, disobeyed road laws

time, another string, to record the date/time of issue of the infringement notice

place, a string to describe where the infringement occurred

fineAmount, the cost of the fine for this infringement.

name, the name of the driver who the infringement notice is given to.

noticeNumber, a unique number given to each infringement. The first notice issued should be given number 1. Each subsequent notice should get the next number in sequence.

These fields should be declared as private.

c- Create a custom constructor in the Infringement class. All of the attributes of the class except noticeNumber should be parameters of this constructor.

d- Write a public method in the Infringement class called printInfringement. This method should print the details about the traffic infringement (all the attributes of the class including the notice number). This method should have a return type void and should not have any parameters.

e- Write a main method which does the following 5 times by using a loop: The user should be asked to enter the type, time, place, fine amount and name for a traffic infringement. A new infringement object should then be created and these values should be passed into the custom constructor. The printInfringement method should then be called to ensure that the class functions as expected.

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

What is the principle of thermodynamics? Explain with examples

Answered: 1 week ago