public static void Main() { Form fm = new Form(); fm.Text = "サンプル"; fm.Width = 400; fm.Height = 300; PictureBox[] pb = new PictureBox[2]; for (int i = 0; i < pb.Length; i++) { pb[i] = new PictureBox(); pb[i].Parent = fm; } Car[] c = new Car[2]; c[0] = new Car(); c[1] = new RacingCar(); for (int i = 0; i < c.Length; i++) { c[i].Move(); pb[i].Image = c[i].GetImage(); pb[i].Top = c[i].Top; pb[i].Left = c[i].Left; } Application.Run(fm); }
public void WorkshopFacadeTest() { var racingCar = new RacingCar(); var streetCar = new StreetCar(); var workshop = new Workshop(); var timeRepairingRacingCar = workshop.Repair(racingCar); var timeRepairingStreetCar = workshop.Repair(streetCar); Assert.AreEqual(timeRepairingRacingCar, 2); }
public static void Main() { Form fm = new Form(); fm.Text = "サンプル"; fm.Width = 300; fm.Height = 200; PictureBox[] pb = new PictureBox[2]; for (int i = 0; i < pb.Length; i++) { pb[i] = new PictureBox(); pb[i].Parent = fm; } Car[] c = new Car[2]; c[0] = new Car(); c[1] = new RacingCar(); for (int i = 0; i < c.Length; i++) { c[i].Move(); pb[i].Image = c[i].GetImage(); pb[i].Top = c[i].Top; pb[i].Left = c[i].Left; } /* * Label lb = new Label(); * * Car c1 = new Car(); * Car c2 = new Car(); * * lb.Parent = fm; * * PictureBox pb = new PictureBox(); * * Car c = new Car(); * c.Move(); * c.Move(); * * pb.Image = c.GetImage(); * pb.Top = c.Top; * pb.Left = c.Left; * * pb.Parent = fm; */ Application.Run(fm); }
private static void PerformDecoratorPattern() { Car car = new Car(); Console.WriteLine("Using a car ..."); Console.WriteLine(car.Run()); RacingCar racingCar = new RacingCar(car); Console.WriteLine("Using a racing car ..."); Console.WriteLine(racingCar.Run()); Console.WriteLine(racingCar.RunFast()); ClassicSlowCar classicSlowCar = new ClassicSlowCar(car); Console.WriteLine("Using classic slow car ..."); Console.WriteLine(classicSlowCar.Run()); Console.ReadKey(); }
private int RepairRacingCar(RacingCar car) { return(2); }