static void Main(string[] args) { var sedan = new Sedan(1); var hatchback = new Hatchback(2); var teslaHQ = new TeslaHq(); teslaHQ.Attach(sedan); teslaHQ.Attach(hatchback); //2.0.0 teslaHQ.MajorUpgrade(); teslaHQ.NotifySoftwareUpdate(); teslaHQ.Detach(hatchback); //2.0.1 teslaHQ.PatchUpdate(); teslaHQ.NotifySoftwareUpdate(); System.Console.WriteLine(sedan.SoftwareVersion); System.Console.WriteLine(hatchback.SoftwareVersion); var cars = new CarsCollection(); cars.AddCar(sedan); cars.AddCar(hatchback); foreach (var car in cars) { System.Console.WriteLine(car.ToString()); } }
public Car CreateCar() { int carCost = 0; string model; bool result = false; int nummberOfBody = 0; int nummberOfEngine = 0; ICarBody bodyCar; IEngine engineCar; string enterTheCost = "Enter the cost of the car"; string choseTheBody = "Choose a car body \r\n 1.Coupe \r\n 2.Hatchback \r\n 3.Minivan "; string choseTheEngine = "Choose a car engine \r\n 1.DieselEngine \r\n 2.ElectricalEngine \r\n 3.GasolineEngine "; Console.WriteLine("Enter the name of the car"); model = Console.ReadLine(); InputValidation(result, enterTheCost, ref carCost, 0, 9223372036854000000); InputValidation(result, choseTheBody, ref nummberOfBody, 1, 3); switch (nummberOfBody) { case 1: bodyCar = new Coupе();; break; case 2: bodyCar = new Hatchback();; break; case 3: bodyCar = new Minivan();; break; default: bodyCar = null; break; } InputValidation(result, choseTheEngine, ref nummberOfEngine, 1, 3); switch (nummberOfEngine) { case 1: engineCar = new DieselEngine();; break; case 2: engineCar = new ElectricalEngine();; break; case 3: engineCar = new GasolineEngine();; break; default: engineCar = null; break; } Console.WriteLine(); return(new Car(engineCar, bodyCar, carCost, model, IdOfCar)); }
public void TestFuelTypeHatchSet() { Hatchback hb = new Hatchback(); hb.FuelType = "Gas"; Assert.Equal("Gas", hb.FuelType); }
public void TestCanDriveHatchSet() { Hatchback hb = new Hatchback(); hb.CanDrive = true; Assert.True(hb.CanDrive); }
public void TestSpaceHatchSet() { Hatchback hb = new Hatchback(); hb.CargoSpace = 10; Assert.Equal(10, hb.CargoSpace); }
public void TestPriceHatchSet() { Hatchback hb = new Hatchback(); hb.Price = 0.0m; Assert.Equal(0.0m, hb.Price); }
public void TestWheelsHatchSet() { Hatchback hb = new Hatchback(); hb.Wheels = 3; Assert.Equal(3, hb.Wheels); }
public void TestDoorsHatchSet() { Hatchback hb = new Hatchback(); hb.Doors = 2; Assert.Equal(2, hb.Doors); }
private static void ThirdWeekExamples() { Console.WriteLine("Instance of AccessModifiers() called myAccMod1"); AccessModifiers myAccMod1 = new AccessModifiers(); Console.WriteLine("Instance of AccessModifiers() called myAccMod2"); AccessModifiers myAccMod2 = new AccessModifiers("This one Has a String"); Console.WriteLine("Indexer Example"); myAccMod1.IndexerExample(); Console.WriteLine("ClassFinalizerSample Class Definitions"); ClassFinalizerSample myCFS = new ClassFinalizerSample(); ClassFinalizerSample myCFS2 = new ClassFinalizerSample("Johnny Quest", 4538702); ClassFinalizerSample myCFS3 = new ClassFinalizerSample("Johnny Quest"); Console.WriteLine("Class Grades Assignment"); ClassGrades myClassGrades = new ClassGrades("Joe ", "Smith", 'E'); (string firstName, string lastName, char Grades) = myClassGrades; Console.WriteLine($"Person Details: First Name: {firstName}, Last Name: {lastName}, Grade: {Grades}"); Console.WriteLine("Example of using NameOf"); Console.WriteLine(myClassGrades.MyGradeType()); DevelopmentClass myDevelopment = new DevelopmentClass(); int x, y; x = myDevelopment.ClassTotal; y = myDevelopment.RoomTotal; Console.WriteLine($"Class Total: {x}, RoomTotal: {y}"); Hatchback myHatchback1 = new Hatchback(); myHatchback1.Color(); myHatchback1.Size(); myHatchback1.Speed(); myHatchback1.Weight(); Console.WriteLine(StaticExample.AddTwoNumbers(1, 2)); Console.WriteLine(Math.Abs(-10)); String Name = "Bob"; if (IsPalinDrome.IsPalindrome(Name)) { Console.WriteLine($"{Name} is a palindrome"); } else { Console.WriteLine($"{Name} is not a palindrome"); } if (IsPalinDrome.IsPalindrome(Name = "Sarah")) { Console.WriteLine($"{Name} is a palindrome"); } else { Console.WriteLine($"{Name} is not a palindrome"); } }
public static void Main() { // Build a collection of all vehicles that fly HotAirBalloon balloon1 = new HotAirBalloon(); HotAirBalloon balloon2 = new HotAirBalloon(); List <IAirbased> flyingstuff = new List <IAirbased>(); flyingstuff.Add(balloon1); flyingstuff.Add(balloon2); // With a single `foreach`, have each vehicle Fly() foreach (IAirbased item in flyingstuff) { item.Fly(); } // Build a collection of all vehicles that operate on roads Motorcycle motorcycle1 = new Motorcycle(); Motorcycle motorcycle2 = new Motorcycle(); Hatchback hondafit = new Hatchback(); Cessna planecar = new Cessna(); List <IGroundbased> groundstuff = new List <IGroundbased>(); groundstuff.Add(motorcycle1); groundstuff.Add(motorcycle2); groundstuff.Add(hondafit); groundstuff.Add(planecar); // With a single `foreach`, have each road vehicle Drive() foreach (IGroundbased item in groundstuff) { item.Drive(); } // Build a collection of all vehicles that operate on water JetSki jetski1 = new JetSki(); JetSki jetski2 = new JetSki(); List <IWaterbased> waterstuff = new List <IWaterbased>(); waterstuff.Add(jetski1); waterstuff.Add(jetski2); // With a single `foreach`, have each water vehicle Drive() foreach (IWaterbased item in waterstuff) { item.Drive(); } }
public void TestWheelsHatchGet() { Hatchback hb = new Hatchback(); Assert.Equal(4, hb.Wheels); }
public void TestScaryFastHatch() { Hatchback hb = new Hatchback(); Assert.False(hb.ScaryFast()); }
public void TestDoorsHatchGet() { Hatchback hb = new Hatchback(); Assert.Equal(4, hb.Doors); }
public void TestPriceHatchGet() { Hatchback hb = new Hatchback(); Assert.Equal(40000.00m, hb.Price); }