akosiraff

Car Class C++

Apr 29th, 2013
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1.  
  2. Download: http://solutionzip.com/downloads/car-class-c/
  3. Implement a class Car with the following properties. A car has a certain fuel efficiency (measured in miles/gallon or liters/km—pick one) and a certain amount of fuel in the gas tank. The efficiency is specified in the constructor, and the initial fuel level is 0. Supply a function drive that simulates driving the car for a certain distance, reducing the fuel level in the gas tank, and functions get_gas, to return the current fuel level, and add_gas, to tank up. Sample usage:
  4. Car my_beemer(29); // 29 miles per gallon
  5. my_beemer.add_gas(20); // Tank 20 gallons
  6. my_beemer.drive(100); // Drive 100 miles
  7. cout << my_beemer.get_gas() << “\n”; // Print fuel remaining
  8.  
  9. Download: http://solutionzip.com/downloads/car-class-c/
Advertisement
Add Comment
Please, Sign In to add comment