Prev | Current Page 240 | Next

Carl Reynolds and Paul Tymann

"Schaum's Outline of Principles of Computer Science"


You should also give the Vehicle class an instance method called changeSpeed. The
changeSpeed method should expect a floating-point value for the new speed, and it should return a
floating-point value representing the difference between the new speed and the previous speed of the
vehicle. Include a public static void main(String[] args) method that creates a few
vehicles, sets some speeds, and reads some variable values, so that you can test your code by launching
the class from the command line.
5.7 Write a Skateboard class that inherits from Vehicle. Override the changeSpeed method for the
Skateboard class, so that instances of the Skateboard class can never exceed 10 mph. If a larger
value is supplied, the method will simply set the speed of the Skateboard to 10.
5.8 Write a Bus class that inherits from Vehicle. An instance of the Bus class must always have a
named driver. In the constructor for a Bus, make sure that your code expects and stores the name of the
driver. Also, the Bus class should have accessor and mutator methods for returning and changing the
name of the driver.
5.9 To the class Vehicle, add a refuel method that expects two parameters, fuelQuantity and
milesSinceLastFueling.


Pages:
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
drukarki fiskalne kraków willa karmazyn międzyzdroje www.books61.hobbitstory.com terapia magnetyczna Informacje o hostingu