Develop a simple rentalcarcompany program for a rental car

Assignment Help Programming Languages
Reference no: EM13806363

Develop a simple RentalCarCompany program for a Rental Car Company, call it whatever you like. We will have two classes, a Car class and aRentalCarCompany class. The RentalCarCompany class will contain several Car objects stored in an array and will have several operations. We will also have a tester class to test the RentalCarCompany class.

Specific Requirements for theCar class:

Default constructor that sets all instance variables to default values.

A parameterizes constructor that takes in parameters to set the class's instance variables : String (the name of the car renter), int (the car number: a number used to identify each rental car the company owns), String (the car name or model), String (the car type, for example, compact or mid size), double (the car's rental rate), and an int (the number of days rented).

Accessor and mutator methods for all the instance variables (see UML Class diagram above)

toString() returns the car renter's name, the car number, name, type, number of doors (2 or 4), car rental rate, and number of days rented. This should all be nicely formatted with one attribute on each line using the '\n' escape character (see sample output below for an example).

The UML class diagram for the Car class looks like this:

Car

carRenter: String

carNum: int

carName: String

carType: String

rate: double

days: int

Car()

Car(String,int,String,String,int, double,int)

getCarRenter(): String

getCarNum(): int

getCarName(): String

getCarType(): String

getCarRate(): double

getNumOfDays(): int

setCarRenter(String)

setCarNum(int)

setCarName(String)

setCarType(String)

setCarRate(double)

setNumOfDays(int)

toString: String

Specific Requirements for the RentalCarCompany class:

Default constructor

Parameterized constructor that takes in the name of the Car Rental Company.

Instance variables include an array of Car objects called theCars to hold information about each car. A String representing the name of the company and a variable called rentCnt the indicates how may cars have been rented (car object actually stored in the array).

A Class constant called NUM_CARS is an int representing the size of the array. For this project, we will assume that the rental car company will not have more than 20 cars, so set the array size to 20.

Methods

Accessor and mutator methods for name instance variable

addReservation method

Adds a Car object to theCars array using the parameters to create a Car object.

An array needs to be created with a fixed size, however number of cars rented at any time may vary therefore to solve this problem we will use a partially filled array (See text for details on partially filled arrays) . The instance field calledrentCnt indicates the actual number of cars currently rented.

getTotalRentalSales - returns a double representing the total sales of all the cars in the array, the sale value formula is the car's (rate * days)

findReservation

Searches the array using a parameter that reprsents a car's carNum.

If the reservation is found, the findReservation method will print out the rental car's information using the car's toStringmethod. If not, the method prints out a message indicating that the reservation was not found.

toString - will print out the information for each rental car by calling the toString method for each Car object. (see sample run below)

The UML class diagram for the RentalCarCompany class looks like this:

RentalCarCompany

theCars: Car[]

name: String

rentCnt : int

NUM_CARS: int

RentalCarCompany()

RentalCarCompany(String)

getName():String

setName(String)

addReservation(String, int, String, String, double, int)

getTotalRentalSales(): double

findReservation(int)

toString(): String

Build a RentalCarTest class to test your application. It should verify the correct operation of the constructor and all public methods in theRentalCarCompany class. Remember to test the addReservation() method, which should add cars to the array, and the findReservation()method, which should be able to find a car in the array of objects if it exists. See the sample output below for a sample run of the test program.

Your source files must have Javadoc comments for each class, method and constructor, with relevant tags.

You should turn in the following files for this assignment:

Car.java

RentalCarCompany.java

RentalCarTest.java

Reference no: EM13806363

Questions Cloud

What is the approximate radius of a nucleus : What is the approximate radius of a nucleus - How many nuclei are present 1h and 49 min later?
Write an essay about the right of habeas corpus : Write an essay about the right of habeas corpus in the context of the war on terror. Your essay should address the following subtopics
Write an essay about islam : Write an essay about islam.
Global organization with a multinational presence : Identify a global organization with a multinational presence. Identify and research a cultural issue that affects this organization's interactions outside the United States.
Develop a simple rentalcarcompany program for a rental car : Develop a simple RentalCarCompany program for a Rental Car Company, call it whatever you like. We will have two classes, a Car class and aRentalCarCompany class
How will we ensure an engaging relevant pedagogy : How will we ensure an engaging relevant pedagogy
How artistic culture in india exhibits from western cultures : discuss how the artistic culture in either India, China, or Japan (select one) exhibits influence from Western cultures.
What orientation of the coil allows : Is the incoming flux equal to the outgoing flux - Why is the outgoing peak higher than the incoming peak?
Explain the jit philosophy : Explain the JIT philosophy. Identify the customer expectations for the service and/or product.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd