public static void RollerbladeTest() { Rollerblade <int, string> myRollerblade = new Rollerblade <int, string>( "plastic", "blue", 10, "intermediate", "noname", new List <Wheels <string> >() { new Wheels <string>("rubber", "mid", new Bearing <int, bool, string>(15, false, "speed", "cupper")), new Wheels <string>("rubber", "mid", new Bearing <int, bool, string>(15, false, "speed", "cupper")), new Wheels <string>("rubber", "mid", new Bearing <int, bool, string>(15, false, "speed", "cupper")) } ); Console.WriteLine("my rollerblade color is : " + myRollerblade.Color); // white List <Wheels <string> > wheelsInMyRollerBlade = myRollerblade.Wheel; Console.WriteLine("\n"); Console.WriteLine("my rollerblade has " + wheelsInMyRollerBlade.Count + " wheels"); Console.WriteLine("my rollerblade's brand is " + myRollerblade.Brand); Console.WriteLine("my rollerblade's material is " + myRollerblade.Material); Console.WriteLine("my rollerblade's color is " + myRollerblade.Color); myRollerblade.Color = "purple"; Console.WriteLine("\n"); Console.WriteLine("my rollerblade's color is " + myRollerblade.Color); //foreach (var item in wheelsInMyRollerBlade) //{ // Console.WriteLine( item.Material ); // Console.WriteLine( item.Performance ); //} Console.WriteLine("wheelsInMyRollerBlade's first wheel bearing type is " + wheelsInMyRollerBlade[0].Bearing.Type); Console.WriteLine("does my wheelsInMyRollerBlade need maintanance? : " + wheelsInMyRollerBlade[0].Bearing.NeedsLubricate()); Console.WriteLine("the speed of my rollerblade is " + myRollerblade.Accelerate("10 km/h")); Console.WriteLine("\n"); Console.WriteLine("does my wheelsInMyRollerBlade need maintanance? : "); int count = 1; foreach (var item in myRollerblade.Wheel) { Console.WriteLine("number " + count + " " + item.Bearing.NeedsLubricate()); count += 1; } myRollerblade.DoMaintanceForBearings(); Console.WriteLine("\n"); Console.WriteLine("after maintanance : "); count = 1; foreach (var item in myRollerblade.Wheel) { Console.WriteLine("number " + count + " " + item.Bearing.NeedsLubricate()); count += 1; } myRollerblade.Brake(); }
public static void QueueAndStackTest() { Queue <Rollerblade <int, string> > myQueue = new Queue <Rollerblade <int, string> >(); Stack <Rollerblade <int, string> > myStack = new Stack <Rollerblade <int, string> >(); Rollerblade <int, string> r1 = new Rollerblade <int, string>( "plastic", "blue", 10, "intermediate", "noname", new List <Wheels <string> >() { new Wheels <string>("rubber", "mid", new Bearing <int, bool, string>(15, false, "speed", "cupper")), new Wheels <string>("rubber", "mid", new Bearing <int, bool, string>(15, false, "speed", "cupper")), new Wheels <string>("rubber", "mid", new Bearing <int, bool, string>(15, false, "speed", "cupper")) } ); //do not use this Rollerblade <int, string> willCreateNullException = new Rollerblade <int, string>(); Rollerblade <int, string> r2 = new Rollerblade <int, string>( "jelly plastic", "black", 12, "advanced", "noname", new List <Wheels <string> >() { new Wheels <string>("composite", "high", new Bearing <int, bool, string>(12, false, "race", "aluminium - carbon")), new Wheels <string>("composite", "high", new Bearing <int, bool, string>(12, false, "race", "aluminium - carbon")), new Wheels <string>("composite", "high", new Bearing <int, bool, string>(12, false, "race", "aluminium - carbon")) } ); Rollerblade <int, string> r3 = new Rollerblade <int, string>( "jelly plastic", "black", 12, "advanced", "noname", new List <Wheels <string> >() { new Wheels <string>("plastic", "low", new Bearing <int, bool, string>(10, false, "speed", "steel")), new Wheels <string>("plastic", "low", new Bearing <int, bool, string>(10, false, "speed", "steel")), new Wheels <string>("plastic", "low", new Bearing <int, bool, string>(10, false, "speed", "steel")) } ); Rollerblade <int, string> r4 = new Rollerblade <int, string>( "jelly plastic", "black", 12, "advanced", "noname", new List <Wheels <string> >() { new Wheels <string>("rubber", "high", new Bearing <int, bool, string>(9, false, "race", "aluminium")), new Wheels <string>("rubber", "high", new Bearing <int, bool, string>(9, false, "race", "aluminium")), new Wheels <string>("rubber", "high", new Bearing <int, bool, string>(9, false, "race", "aluminium")) } ); myQueue.Enqueue(r1); myQueue.Enqueue(r2); myQueue.Enqueue(r3); myQueue.Enqueue(r4); myQueue.Dequeue(); Console.WriteLine("how many objects I have in myQueue " + myQueue.Count); Console.WriteLine(myQueue.Peek().Wheel[0].Bearing.Material); myStack.Push(r1); myStack.Push(r2); myStack.Push(r3); myStack.Push(r4); myStack.Pop(); Console.WriteLine("how many objects I have in myStack " + myStack.Count); Console.WriteLine(myStack.Peek().Wheel[0].Bearing.Material); }