Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Coding Assignment 2 - CISC 124 - Introduction to Computer Science II (ASO) S22

DESCRIPTION

Overview - Order of Submission

The following assignment has a peer review component. Here is the order of submission:

1. Read the activity description and prepare the relevant ile.

2. Submit your ile in FeedbackFruits and start the peer review process (instructions to follow).

3. Review and revise your work (optional).

4. Submit your inal work in OnQ.

Description

Learning Goals: In this assignment, we are learning how to write a series of classes that incorporate the concept of inheritance to share attributes between a hierarchy of classes.

You have been given a contract by the provincial government to develop software that will keep      record of the vehicles registered within the province. For simplicity, our software will only focus on the following types of Vehicle: Car, Truck and Motorcycle. Notice that the Car, Truck, and                Motorcycle classes are subclasses of the Vehicle class.

 

   Begin by writing a Vehicle class which will be used to represent all types of vehicles. Next, write

three sub-classes: Car, Truck, and Motorcycle. These sub-classes will contain the variables and methods that are speciic to those particular types of vehicles.

You will write a CarOwner class which will represent the owner of a vehicle.

You will write a Registry class. This class is a simple collection class that represents a collection of vehicle objects.

The Vehicle class will have the following instance variables:

- registrationNumber (vehicle's registration number)

- owner (a CarOwner object representing the owner of the vehicle)

- odometerReading (representing the odometer reading of the vehicle)

- make (make of the vehicle -- i.e. Chevrolet)

- model (model of the vehicle -- i.e. Silverado)

- year (model year of the vehicle. The model year of the vehicle must be 1980 or later)

- numWheels (number of wheels on the vehicle. Every vehicle has a minimum of 2 wheels)

- plateNumber (the license plate number. This will be a combination of letters (L) and numbers (#). In Ontario, a license plate is of the form 4L's and 3#'s. As an example, a license plate may be: HGKW

815. Every vehicle's plate number must be of the correct letter-number combination).

In addition to the instance variables inherited from the Vehicle parent class, the Car class will have the following instance variables:

- numSeats (number of seats in the Car)

- isSUV (indicating whether the Car is a sport utility vehicle -- SUV).

In addition to the instance variables inherited from the Vehicle class, the Truck class will have the following instance variables:

- isSemi (True if the truck is a transport truck, False if the truck is another type -- i.e. pickup).

- loadCapacity (the weight that the truck can hold, measured in pounds).

The Motorcycle class will inherit all of its instance variables from the Vehicle class. Think about     why we might choose to create a Motorcycle class if it inherits all of the instance variables and          methods from the vehicle class, but doesn't specify any of its own instance variables or override any of the methods from the Vehicle class.

The CarOwner class will include the following instance variables:

- name (the name of a driver)

- age (the age of a driver)

- licenseNumber (the license number of a driver - this is different from the license plate number)

- yearsDriving (the number of years that a driver has been driving).

The Registry class will include two ields:

- vehicleCollection (an ArrayList to hold a collection of registered vehicle objects)

- numVehicles (the number of vehicles currently registered in the province).

REQUIRED METHODS

   Each of your classes should provide accessor (“getter”) and mutator (“setter”) methods for each of

the instance variables of the class. For example, your Vehicle class should include a mutator       method for setting the mileage and setting the plate number for an instance of a Vehicle object.

   Each of your classes should also include a toString method that prints out a string representation

of an instance of the object. Your Vehicle parent class should have its own toString method which the children classes will "override" to print out information speciic to the child class. For example, the toString method for a Truck will print out information about the number of axles - this would  not apply when printing the string representation of a Motorcycle object.

   In your Truck class, include a function called getNumberAxles(). The number of axles returns how

many axles are on the truck. The number of axles is the number of wheels divided by 2.

   The Registry class should include the following functions:

   addVehicle - adds a vehicle object to the registry.

   printRegistry - print the vehicles that are currently inventoried in the registry.

   averageMileage - calculates the average mileage of all vehicles in the registry (using the

odometerReading attribute of the vehicles).

ERROR CHECKING & INFORMATION HIDING

Error Checking

You are required to check for the following errors in user input.

   If there is an attempt made to create an instance of a Vehicle for which the vehicle's year is earlier

than 1980, throw an exception and print out the message (“Illegal year - you need to buy a newer vehicle!”).

   If the "setMileage" method in the Vehicle class is called, your program should verify that

the new value for the mileage is not less than the old value for the mileage. If it is, throw an exception and print out the message ("Illegal mileage - nice try!").

   If there is an attempt to set the number of wheels of any vehicle to less than two, throw an

exception and print out the message ("Illegal number of wheels - buy a unicycle!").

   If there is an attempt to set the vehicle's plate number to an illegal value (i.e. doesn't satisfy the

letter-number combination of 4 letters and 3 numbers), throw an exception and print out the message ("Illegal license plate!").

   If there is an attempt to set the age or yearsDriving instance variable of a Person object to a value

less than 0, throw an exception and print out the message ("Illegal value!").

Information Hiding

Marks will be allocated according to how well you have implemented the principles of information hiding in the development of your class. Reminders:

   All instance and class variables should be private. This ensures that other classes are not able to

modify the values of these attributes. Any changes to the values of the attributes should be made by invoking the "getter" and "setter" methods of the class.

   Any instance variables that are included in a parent class must NOT be redeined in a child class.

For example, since the instance variable "make" is included in the Vehicle class, it should not be redeined in the Car, Motorcycle or Truck classes. Instead, use the super keyword to access the constructor of the parent class.

Please ensure that your class includes accessor ("getter") and mutator ("setter") methods for each of the instance variables.

Constants should be private unless they need to be used by other classes.

Any “helper methods” should be private. A helper method” is a method that you write to help implement the required methods.

   You will need to write an exception class called "IllegalVehicle". This exception class only needs

the one constructor that accepts a String type message.

Throw an "IllegalVehicle" exception object if an attempt is made to set or alter any of the attributes to illegal values.

Please ensure that your classes include accessor (“getter”) and mutator (“setter”) methods for each of the instance variables.

PEER REVIEW

This assignment includes a peer review feature. Before you submit this assignment to the teaching   team we would like you to submit it to be reviewed by your peers. The purpose of the peer review     activity is to provide you with the opportunity to collaborate and learn from your peers and for your peers to learn from you. Once you receive feedback from your peer, you have the option to correct   your work before submitting it for grade.

Instructions

You will submit your work through a web-based application called FeedbackFruits. Click here for help on how to submit your FeedbackFruits peer review

Each student will review (anonymously) another student’s work according to the rubric below.

When reviewing your peer’s work, keep a positive mindset and positive intentions, you are helping you peer improve.

This review is worth 2% of your overall grade in the course.

Submit and review work in FeedbackFruits

Peer Evaluating Rubric

On a scale of 3-0, please rate your peer’s code.

3- Very good

2 - some improvements are required

1 - signiicant improvements required

0 - No submission

 

3

2

1

0

Comments

Eficiency

Clean code,           indicates that the codewas                adequately            developed

 

 

 

 

 

Maintainability

Readable other

people, a

combination of

short, simple,

consistent and

useful naming

with clear logic.

 

 

 

 

 

Well structured

The various

objects in the

code working

optimally

together.

 

 

 

 

 

Follows standards

The code follows the assignment   description and  adheres to our    code style             standards.

 

 

 

 

 

 

FINAL SUBMISSION

Submit your inal work in OnQ to the following assignment submission folder