Rate this paper
  • Currently rating
  • 1
  • 2
  • 3
  • 4
  • 5
5.00 / 2
views 1423 | downloads 841
Paper Topic:

Object-oriented Programming

Object-Oriented Programming

This project is an exercise in object-oriented project design . It creates a Car List project using four classes , one used in defining the nominal class Car , the Car List which holds a collection of Car objects the Car List Demo which tests the project , and an accessory Input Reader class

Part (1

UML Class Diagram

Figure1 . The UML class diagram of the project

Part (2

The Project Source Code (a . class Car This class defines the attributes and method of the Car object author Insert Name here version

Insert Version here

public class Car / instance variables - replace the example below with your own

private String registration_number

private String manufacturer

private String model

private int value

private int year Creates a new instance of the class Car

public Car

getValues Get the input values for each Car

void getValues

InputReader input new InputReader

System .out .println "Input the Car 's registration number

registration_number input .getString

System .out .println "Input the Car 's manufacturer

manufacturer input .getString

System .out .println "Input the Car 's model

model input .getString

System .out .println "Input the Car 's value

value input .getInt

System .out .println "Input the Car 's year

year input .getInt This method checks for the validity of the car 's field values param list_of_cars The list of Cars that are in the current collection return The validity state of the inputs

boolean validate (CarList list_of_cars /test for uniqueness of the registration number

for (int i 0 i8

return false

if (value 0 value1900 year 2100

return false

return true Prints the field values of this Car

void printTask

System .out .println "\nField values for Car registration_number

System .out .println "Manufacturer manufacturer

System .out .println "Model model

System .out .println "Value value

System .out .println "Year year Used to get the registration number of the Car return The desired registration number

String getRegistrationNumber

return registration_number Used to get the manufacturer of the Car return The desired manufacturer

String getManufacturer

return manufacturer Used to get the model of the Car return The desired model

String getModel

return model Used to get the market value of the Car return The desired market value in pounds

int getValue

return value Used to get the year of this Car model return The desired year

int getYear

return year Sets the Car 's registration number param reg_num The new registration number

void setRegistrationNumber (String reg_num

registration_number reg_num Sets the Car 's manufacturer param man The new value for manufacturer

void setManufacturer (String man

manufacturer man Sets the Car 's model param mod The new model

void setModel (String mod

model mod Sets the Car 's marketvalue param val The new market value

void setValue (int val

value val Sets the Car 's year param yr The new value for the field : year

void setYear (int yr

year yr (b ) The class CarList This class hosts a collection of multiple car objects author Insert your name here version V1 .0

import java .util

public class CarList

ArrayList...

16 pages
339.0 KB
Free sing-up

Not the Essay You're looking for? Get a custom essay (only for $12.99)