static void Main(string[] args) { Zero fxs = new Zero() { CurrentChargePercentage = 10 }; Zero fx = new Zero() { CurrentChargePercentage = 30 }; Tesla modelS = new Tesla() { CurrentChargePercentage = 45 }; List <IElectricVehicle> electricVehicles = new List <IElectricVehicle>() { fx, fxs, modelS }; Console.WriteLine("Electric Vehicles"); foreach (IElectricVehicle ev in electricVehicles) { Console.WriteLine($"{ev.CurrentChargePercentage}"); } foreach (IElectricVehicle ev in electricVehicles) { // This should charge the vehicle to 100% ev.ChargeBattery(); } foreach (IElectricVehicle ev in electricVehicles) { Console.WriteLine($"{ev.CurrentChargePercentage}"); } /***********************************************/ Ram ram = new Ram(); Cessna cessna150 = new Cessna(); List <IGasVehicles> gasVehicles = new List <IGasVehicles>() { ram, cessna150 }; Console.WriteLine("Gas Vehicles"); foreach (IGasVehicles gv in gasVehicles) { Console.WriteLine($"{gv.CurrentTankPercentage}"); } foreach (IGasVehicles gv in gasVehicles) { // This should completely refuel the gas tank gv.RefuelTank(); } foreach (IGasVehicles gv in gasVehicles) { Console.WriteLine($"{gv.CurrentTankPercentage}"); } }
static void Main(string[] args) { // Electric Powered Rides Zero fx = new Zero(); Tesla modelS = new Tesla(); // List of electric vehicles List <ElectricVehicle> electricVehicles = new List <ElectricVehicle>() { fx, modelS }; electricVehicles.ForEach(ev => ev.ChargeBattery()); // Gas Powered Rides //(fuelCap, gasLev) Cessna myCessna = new Cessna(120, 50); Ram myRam = new Ram(10, 3); Console.WriteLine($"The Ram is entering the fueling station with {myRam.gasLevel} gallons in the tank"); Console.WriteLine($"The Cessna is entering the fueling station {myCessna.gasLevel} gallons in the tank"); // List of gas vehicles List <GasVehicle> gasVehicles = new List <GasVehicle>() { myCessna, myRam }; // Battery station instance BatteryStation batteryStation = new BatteryStation(); // Gas station instance and pass the new instance capacity at the gas station GasStation gasStation = new GasStation(3); // refuel all gas vehicles as the gas station if there is room. Capacity is (3)--see line 37 if (gasStation.Refuel(gasVehicles) != null) { Console.WriteLine("Lets Fuel Em Up!"); } else { Console.WriteLine("Too many vehicles, get the hell out!"); } Console.WriteLine($"The Ram is leaving the fueling station with {myRam.gasLevel} gallons in the tank. Ahhh, a full tank!"); Console.WriteLine($"The Ram is leaving the fueling station with {myCessna.gasLevel} gallons in the tank. Ahhh, a full tank!"); // Output // System.Console.WriteLine("-------------"); // myRam.Drive(); // myRam.Turn("left"); // myRam.Stop(); // System.Console.WriteLine("-------------"); // myCessna.Drive(); // myCessna.Turn("right"); // myCessna.Stop(); // System.Console.WriteLine("-------------"); // fx.Drive(); // fx.Turn("right"); // fx.Stop(); // System.Console.WriteLine("-------------"); // modelS.Drive(); // modelS.Turn("left"); // modelS.Stop(); // System.Console.WriteLine("-------------"); }
static void Main(string[] args) { /* INHERITANCE */ Zero fxs = new Zero() { MainColor = "Red" }; Tesla modelS = new Tesla() { MainColor = "Black" }; Cessna mx410 = new Cessna() { MainColor = "White" }; Ram fifteenHundred = new Ram() { MainColor = "Blue" }; fxs.Drive(); fxs.Turn("left"); fxs.Stop(); modelS.Drive(); modelS.Turn("left"); modelS.Stop(); mx410.Drive(); mx410.Turn("right"); mx410.Stop(); fifteenHundred.Drive(); fifteenHundred.Turn("right"); fifteenHundred.Stop(); /***********************************************/ /* INTERFACE */ Zero sr = new Zero() { CurrentChargePercentage = "67%" }; Zero ds = new Zero() { CurrentChargePercentage = "42%" }; Tesla modelX = new Tesla() { CurrentChargePercentage = "86%" }; List <IElectricVehicle> electricVehicles = new List <IElectricVehicle>() { sr, ds, modelX }; Console.WriteLine("Electric Vehicles"); foreach (IElectricVehicle ev in electricVehicles) { Console.WriteLine($"{ev.CurrentChargePercentage}"); } foreach (IElectricVehicle ev in electricVehicles) { // This should charge the vehicle to 100% ev.ChargeBattery(); } foreach (IElectricVehicle ev in electricVehicles) { Console.WriteLine($"{ev.CurrentChargePercentage}"); } /***********************************************/ Ram ram = new Ram() { CurrentTankPercentage = "32%" }; Cessna cessna150 = new Cessna() { CurrentTankPercentage = "50%" }; List <IGasVehicle> gasVehicles = new List <IGasVehicle>() { ram, cessna150 }; Console.WriteLine("Gas Vehicles"); foreach (IGasVehicle gv in gasVehicles) { Console.WriteLine($"{gv.CurrentTankPercentage}"); } foreach (IGasVehicle gv in gasVehicles) { // This should completely refuel the gas tank gv.RefuelTank(); } foreach (IGasVehicle gv in gasVehicles) { Console.WriteLine($"{gv.CurrentTankPercentage}"); } }
static void Main(string[] args) { Zero fxs = new Zero(); // Tesla modelS = new Tesla(); Cessna mx410 = new Cessna(); Tesla electric = new Tesla() { Name = "Fancy Tesla", BatteryKWh = 200.00, MainColor = "red", MaximumOccupancy = "4", CurrentChargePercentage = 15.0 }; Cessna sedan = new Cessna() { Name = "Cessna Sedan", MainColor = "green", MaximumOccupancy = "6", FuelCapacity = 18.50, CurrentTankPercentage = 25, }; List <IElectric> electricVehicles = new List <IElectric>() { electric }; Console.WriteLine("Electric Vehicles List:"); foreach (IElectric ev in electricVehicles) { Console.WriteLine($"{ev.Name}"); Console.WriteLine($"Battery level before charge was at {ev.CurrentChargePercentage}%"); } foreach (IElectric ev in electricVehicles) { // This should charge the vehicle to 100% ev.ChargeBattery(); break; } foreach (IElectric ev in electricVehicles) { Console.WriteLine($"After Charge: {ev.CurrentChargePercentage}%"); } Console.WriteLine("/***********************************************/"); // Ram ram = new Ram(); // Cessna cessna150 = new Cessna(); List <IGasVehicle> gasVehicles = new List <IGasVehicle>() { sedan, }; Console.WriteLine("Gas Vehicles List :"); foreach (IGasVehicle gv in gasVehicles) { Console.WriteLine($"{gv.Name}"); Console.WriteLine($"Should we fill up? Tank level:{gv.CurrentTankPercentage}%"); } foreach (IGasVehicle gv in gasVehicles) { // This should completely refuel the gas tank gv.RefuelTank(); Console.WriteLine($"We got gas"); } foreach (IGasVehicle gv in gasVehicles) { Console.WriteLine($"{gv.CurrentTankPercentage}"); } }
static void Main(string[] args) { //instanstiating new classes Zero fxs = new Zero(); fxs.BatteryKwh = 300.00; fxs.CurrentChargePercentage = 20; Zero fx = new Zero(); fx.BatteryKwh = 100.00; fx.CurrentChargePercentage = 50; Tesla modelS = new Tesla(); modelS.BatteryKwh = 60; modelS.CurrentChargePercentage = 30; List <IElectricVehicle> electricVehicles = new List <IElectricVehicle>() { fx, fxs, modelS }; Console.WriteLine("Electric Vehicles"); foreach (IElectricVehicle ev in electricVehicles) { Console.WriteLine($"{ev.CurrentChargePercentage}"); } //iterating through the list of electric vehicles foreach (IElectricVehicle ev in electricVehicles) { // This should charge the vehicle to 100% ev.ChargeBattery(); } foreach (IElectricVehicle ev in electricVehicles) { Console.WriteLine($"{ev.CurrentChargePercentage}"); } /***********************************************/ Ram ram = new Ram(); ram.FuelCapacity = 60.20; ram.CurrentTankPercentage = 70; Cessna cessna150 = new Cessna(); cessna150.FuelCapacity = 90.21; cessna150.CurrentTankPercentage = 20; List <IGasVehicle> gasVehicles = new List <IGasVehicle>() { ram, cessna150 }; Console.WriteLine("Gas Vehicles"); foreach (IGasVehicle gv in gasVehicles) { Console.WriteLine($"{gv.CurrentTankPercentage}"); } foreach (IGasVehicle gv in gasVehicles) { // This should completely refuel the gas tank gv.RefuelTank(); } foreach (IGasVehicle gv in gasVehicles) { Console.WriteLine($"{gv.CurrentTankPercentage}"); } }
static void Main(string[] args) { Zero fxs = new Zero() { MainColor = "Chartreuse", MaximumOccupancy = "1-2 bodies.", CurrentBatteryKWh = 0.70 }; Zero fx = new Zero() { MainColor = "Dark Salmon", MaximumOccupancy = "1-2 bodies", CurrentBatteryKWh = 0.80 }; Tesla modelS = new Tesla() { MainColor = "Tan", MaximumOccupancy = "5 bodies", CurrentBatteryKWh = 0.89 }; List <IBatteryPowered> electricVehicles = new List <IBatteryPowered>() { fx, fxs, modelS }; Console.WriteLine("Electric Vehicles"); foreach (IBatteryPowered ev in electricVehicles) { Console.WriteLine($"{ev.CurrentChargePercentage()}"); } foreach (IBatteryPowered ev in electricVehicles) { // This should charge the vehicle to 100% ev.ChargeBattery(); } Console.WriteLine(""); foreach (IBatteryPowered ev in electricVehicles) { Console.WriteLine($"{ev.CurrentChargePercentage()}"); } Console.WriteLine(""); /***********************************************/ Ram ram = new Ram() { MainColor = "Cadet Blue", MaximumOccupancy = "3 bodies", CurrentFuel = 0.40 }; Cessna cessna150 = new Cessna() { MainColor = "Light Cyan", MaximumOccupancy = "8 bodies", CurrentFuel = 0.42 }; List <IGasPowered> gasVehicles = new List <IGasPowered>() { ram, cessna150 }; Console.WriteLine("Gas Vehicles"); foreach (IGasPowered gv in gasVehicles) { Console.WriteLine($"{gv.CurrentTankPercentage()}"); } foreach (IGasPowered gv in gasVehicles) { // This should completely refuel the gas tank gv.RefuelTank(); } Console.WriteLine(""); foreach (IGasPowered gv in gasVehicles) { Console.WriteLine($"{gv.CurrentTankPercentage()}"); } }
static void Main(string[] args) { Tesla car = new Tesla() { MainColor = "black", MaximumOccupancy = "20", BatteryKWh = 10.0 }; Zero motorcycle = new Zero() { MainColor = "black", MaximumOccupancy = "20", BatteryKWh = 15.0 }; List <IElectricVehicle> electricVehicles = new List <IElectricVehicle>() { motorcycle, car }; Console.WriteLine("Electric Vehicles"); foreach (IElectricVehicle ev in electricVehicles) { Console.WriteLine($"{ev.CurrentChargePercentage:N2}"); } foreach (IElectricVehicle ev in electricVehicles) { // This should charge the vehicle to 100% ev.ChargeBattery(); } foreach (IElectricVehicle ev in electricVehicles) { Console.WriteLine($"{ev.CurrentChargePercentage:N2}"); } /***********************************************/ Cessna plane = new Cessna() { MainColor = "blue", MaximumOccupancy = "6", FuelCapacity = 30.0 }; Ram truck = new Ram() { MainColor = "red", MaximumOccupancy = "20", FuelCapacity = 20.0 }; List <IGasVehicle> gasVehicles = new List <IGasVehicle>() { truck, plane }; Console.WriteLine("Gas Vehicles"); foreach (IGasVehicle gv in gasVehicles) { Console.WriteLine($"{gv.CurrentTankPercentage:N2}"); } foreach (IGasVehicle gv in gasVehicles) { // This should completely refuel the gas tank gv.RefuelTank(); } foreach (IGasVehicle gv in gasVehicles) { Console.WriteLine($"{gv.CurrentTankPercentage:N2}"); } }
static void Main(string[] args) { Zero fxs = new Zero() { MainColor = "Midnight Blue", CurrentChargePercentage = 50 }; Tesla modelS = new Tesla() { MainColor = "Burgundy", CurrentChargePercentage = 20 }; Cessna mx410 = new Cessna() { MainColor = "White", CurrentTankPercentage = 22 }; Ram truck = new Ram() { MainColor = "Silver", CurrentTankPercentage = 12 }; List <Vehicle> allVehicles = new List <Vehicle>() { fxs, modelS, truck, mx410 }; allVehicles.ForEach(vehicle => { vehicle.Drive(); vehicle.Turn("right"); vehicle.Stop(); Console.WriteLine(); }); List <IElectricVehicle> electricVehicles = new List <IElectricVehicle>() { fxs, modelS }; Console.WriteLine("Electric Vehicles:"); electricVehicles.ForEach(ev => { Console.WriteLine($"{ev.CurrentChargePercentage}"); // This should charge the vehicle to 100% ev.ChargeBattery(); Console.WriteLine($"{ev.CurrentChargePercentage}"); Console.WriteLine(); }); List <IGasVehicle> gasVehicles = new List <IGasVehicle>() { truck, mx410 }; Console.WriteLine("Gas Vehicles:"); gasVehicles.ForEach(gv => { Console.WriteLine($"{gv.CurrentTankPercentage}"); // This should completely refuel the gas tank gv.RefuelTank(); Console.WriteLine($"{gv.CurrentTankPercentage}"); Console.WriteLine(); }); }