Question: CS 04113 2 Crate two classes VehicleDisplay and Odometer as described below. Creame class, Odometer, that contains three fields: distance, time, and speed whose types

 CS 04113 2 Crate two classes VehicleDisplay and Odometer as described

CS 04113 2 Crate two classes VehicleDisplay and Odometer as described below. Creame class, Odometer, that contains three fields: distance, time, and speed whose types are double-precision floating point. Define a constructor that takes no parameters. Set te fieds to default values such that the speed is 0.0, the time is 0.0, and distance is 0. Define a method computeDist that returns a distance value based on the follow- ing formula: distance-speed x time Creame another class. VehicleDisplay, that contains four fields currentDisplay whose type is integer, distance whose type is double-precision floating point. aircon whose type is boolean (ie. i air conditioning is on, then it is true; else it is false), and odometer whose type is Odometer Deline a coastructor that takes three parameters of appropriate type. Assign aircon variable to one parameter value. The distance variable is assigned a return value from an internal method computeDistance that takes the other two parameters, The currentDisplay variable is set to a default value 0. A new Odometer objoct is created and assigned to odometer Define a method computeDistance that takes two parumeters of appropriate type. It retums the value of the method computeDist of Odometer Define the mutator setCurrent Display that takes a single parameter of the ap- propriate type. It updates the current Display variable. There are four possible alues0,,2 3, and 4 for currentDisplay variable. An update to currentDis play variable oecurs only when the parameter is one of the possible valucs, clsc an error message is printed out (Hint: you will decide what message to print Define a method show DisplayOption that takes no parameter. Use the switch statement to perform the following When currentDisplay is 0, print "Defaul front page 2 When When current Display is 3, print "Navigator" When current Display is4, print "DVD player currentDisplay is l or 2, print ,FM and XM Radio". Hinl: Remember to include documentation comments where necessary and fol low good programming style. Marks will be deducted for missing documenta- tion comments) (35 marks)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!