static void Main(string[] args) { Odometer trip1 = new Odometer(); Odometer trip2 = new Odometer(100, 4.5); Console.WriteLine(trip1.FuelUsed); Console.WriteLine(trip1.MilesDriven); trip1.calculateMPG(); Console.WriteLine("\n"); Console.WriteLine(trip2.FuelUsed); Console.WriteLine(trip2.MilesDriven); Console.WriteLine(trip2.calculateMPG()); Console.WriteLine("\n"); Console.WriteLine(trip1.ToString()); Console.WriteLine("\n"); Console.WriteLine(trip2.ToString()); Console.WriteLine("\n"); trip2.Reset(); Console.WriteLine(trip2.ToString()); }
static void Main(string[] arguments) { Odometer odometer = new Odometer(10, 250); Console.WriteLine($"Initial reading: {odometer}"); odometer.Add(3, 60); Console.WriteLine($"After using 3 gallons over 60 miles: {odometer.MilesPerGallon()}"); odometer.ResetMeter(); Console.WriteLine($"Reset: {odometer}"); }
static void Main(string[] args) { Odometer trip1 = new Odometer(); trip1.Add(50, 10); Console.WriteLine("fuel used for trip1 is: " + trip1.mpg()); Odometer trip2 = new Odometer(50, 10); trip2.Add(100, 20); Console.WriteLine("fuel used for trip2 is: " + trip2.mpg()); Console.WriteLine(trip1.toString()); Console.WriteLine(trip2.toString()); if (trip1.equals(trip1)) { Console.WriteLine("The two object are the same"); } else { Console.Write("The two objects are NOT the same"); } //toDo : reset //ToDo : test toString(); //test every method }
public bool equals(Odometer other) { // return (this.miles == other.miles) && (this.fuelUsed == other.fuelUsed); return((this.getMiles() == other.getMiles()) && (this.getFuelUsed() == other.getFuelUsed())); }