[Test] //Test 3 public void CannotCreateBoatWithNegativeOars() { Assert.Catch(() => { Rowboat Slowly = new Rowboat("Slowly", 1500, -2); }); }
[Test] //Test 8 public void CanDoubleOarsOnRowboat() { Rowboat Speedy = new Rowboat("Speedy", 1500, 2); Assert.IsTrue(Speedy.Number_oars == 2); Speedy.EnhanceSpeed(); Assert.IsTrue(Speedy.Number_oars == 4); }
public static void Main() { string xyz = ""; Boat b1 = new Boat(); Sailboat b2 = new Sailboat(); Rowboat b3 = new Rowboat(); b2.SetLength(32); xyz = b1.Move(); xyz += b3.Move(); xyz += b2.Move(); MessageBox.Show(xyz); }
static void Main(string[] args) { Motorboat Titanic = new Motorboat("Titanic", 45000, 50); Motorboat Baywatch = new Motorboat("Baywatch", 25000, 60); Console.WriteLine("Titanic's speed: {0}", Titanic.Speed); Console.WriteLine("Baywatch's price: {0}", Baywatch.Price); Baywatch.Price = 26000; Console.WriteLine("Baywatch's price after resetting: {0}", Baywatch.Price); Titanic.EnhanceSpeed(); Console.WriteLine("Titanic's speed after doubling: {0}", Titanic.Speed); Rowboat Speedy = new Rowboat("Speedy", 1500, 2); Console.WriteLine("Speedy's price: {0}", Speedy.Price); //Task 3.4: array Console.WriteLine("array:"); IBoat[] array = new IBoat[] { Titanic, Baywatch, Speedy }; foreach (var i in array) { Console.WriteLine("boat {0}: after using enhance speed method: {1}", i.Name, i.EnhanceSpeed()); } //Task 4.2: serialization Console.WriteLine("serialization:"); foreach (var i in array) { string jsonstring = JsonConvert.SerializeObject(i); Console.WriteLine(jsonstring); } }