From f818383310225df2ac7f74b96c6ac50b562d9e55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=AD=9D=E6=B6=B5?= <97312789@qq.com> Date: Tue, 25 May 2021 15:26:20 +0800 Subject: [PATCH 1/2] 1 --- .../Animal/Animal.cs" | 13 +++++++ .../Animal/Cat.cs" | 21 +++++++++++ .../Animal/Dog.cs" | 21 +++++++++++ .../Animal/Duck.cs" | 21 +++++++++++ .../Animal/IClimbTree.cs" | 13 +++++++ .../Animal/ISwim.cs" | 13 +++++++ .../Animal/Monkey.cs" | 21 +++++++++++ .../Animal/Program.cs" | 35 +++++++++++++++++++ .../PlaneBirdeSuperMan/Animal.cs" | 13 +++++++ .../PlaneBirdeSuperMan/Bird.cs" | 34 ++++++++++++++++++ .../PlaneBirdeSuperMan/IFlyable.cs" | 15 ++++++++ .../PlaneBirdeSuperMan/Plane.cs" | 31 ++++++++++++++++ .../PlaneBirdeSuperMan/Program.cs" | 30 ++++++++++++++++ .../PlaneBirdeSuperMan/SuperMan.cs" | 31 ++++++++++++++++ .../PlaneBirdeSuperMan/Vehicle.cs" | 13 +++++++ 15 files changed, 325 insertions(+) create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Animal.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Cat.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Dog.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Duck.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/IClimbTree.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/ISwim.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Monkey.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Program.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Animal.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Bird.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/IFlyable.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Plane.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Program.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/SuperMan.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Vehicle.cs" diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Animal.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Animal.cs" new file mode 100644 index 0000000..39454a0 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Animal.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + abstract class Animal + { + public abstract void eat(); + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Cat.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Cat.cs" new file mode 100644 index 0000000..6a6761b --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Cat.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Cat: Animal, IClimbTree + { + public void ClimbTree() + { + Console.WriteLine("Cat在ClimbTree"); + } + + public override void eat() + { + Console.WriteLine("Cat在eat"); + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Dog.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Dog.cs" new file mode 100644 index 0000000..d92fd80 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Dog.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Dog: Animal, IClimbTree + { + public void ClimbTree() + { + Console.WriteLine("Dog在ClimbTree"); + } + + public override void eat() + { + Console.WriteLine("Dog在eat"); + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Duck.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Duck.cs" new file mode 100644 index 0000000..5224f25 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Duck.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Duck: Animal, ISwim + { + public override void eat() + { + Console.WriteLine("duck在eat"); + } + + public void swim() + { + Console.WriteLine("duck在swim"); + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/IClimbTree.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/IClimbTree.cs" new file mode 100644 index 0000000..e2ff67c --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/IClimbTree.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + interface IClimbTree + { + void ClimbTree(); + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/ISwim.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/ISwim.cs" new file mode 100644 index 0000000..aa79a79 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/ISwim.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + interface ISwim + { + void swim(); + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Monkey.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Monkey.cs" new file mode 100644 index 0000000..b42a4e6 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Monkey.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Monkey: Animal, IClimbTree + { + public void ClimbTree() + { + Console.WriteLine("Monkey在ClimbTree"); + } + + public override void eat() + { + Console.WriteLine("Monkey在eat"); + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Program.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Program.cs" new file mode 100644 index 0000000..425f6e8 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Animal/Program.cs" @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Program + { + static void Main(string[] args) + { + IClimbTree ict = new Cat(); + ClimbTree(ict); + + ISwim swim = new Duck(); + Swim(swim); + + Animal a = new Dog(); + Eat(a); + } + static void ClimbTree(IClimbTree ict) + { + ict.ClimbTree(); + } + static void Swim(ISwim iswim) + { + iswim.swim(); + } + static void Eat(Animal animal) + { + animal.eat(); + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Animal.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Animal.cs" new file mode 100644 index 0000000..8d2bf5b --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Animal.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + abstract class Animal + { + public abstract void Eat(); + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Bird.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Bird.cs" new file mode 100644 index 0000000..0144b9c --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Bird.cs" @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Bird : Animal, IFlyable + { + public void LayEggs() { + Console.WriteLine("鸟在LayEggs"); + } + public override void Eat() + { + Console.WriteLine("鸟在Eat"); + } + + public void Fly() + { + Console.WriteLine("鸟在Fly"); + } + + public void Land() + { + Console.WriteLine("鸟在Land"); + } + + public void TakeOff() + { + Console.WriteLine("鸟在TakeOff"); + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/IFlyable.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/IFlyable.cs" new file mode 100644 index 0000000..1dc75ac --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/IFlyable.cs" @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + interface IFlyable + { + void TakeOff(); + void Fly(); + void Land(); + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Plane.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Plane.cs" new file mode 100644 index 0000000..9a761e0 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Plane.cs" @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Plane : Vehicle, IFlyable + { + public override void CarryPassange() + { + Console.WriteLine("飞机在CarryPassange"); + } + + public void Fly() + { + Console.WriteLine("飞机在Fly"); + } + + public void Land() + { + Console.WriteLine("飞机在Land"); + } + + public void TakeOff() + { + Console.WriteLine("飞机在TakeOff"); + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Program.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Program.cs" new file mode 100644 index 0000000..f9f244d --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Program.cs" @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + static void Main(string[] args) + { + IFlyable ifa = new Bird(); + Flyable(ifa); + + Vehicle v = new Plane(); + CarryPassange(v); + } + + static void Flyable(IFlyable ifa) { + ifa.Fly(); + ifa.Land(); + ifa.TakeOff(); + } + + static void CarryPassange(Vehicle v) { + v.CarryPassange(); + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/SuperMan.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/SuperMan.cs" new file mode 100644 index 0000000..0b0bd41 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/SuperMan.cs" @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class SuperMan : Animal, IFlyable + { + public override void Eat() + { + Console.WriteLine("超人Eat"); + } + + public void Fly() + { + Console.WriteLine("超人Fly"); + } + + public void Land() + { + Console.WriteLine("超人Land"); + } + + public void TakeOff() + { + Console.WriteLine("超人TakeOff"); + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Vehicle.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Vehicle.cs" new file mode 100644 index 0000000..96485cd --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/PlaneBirdeSuperMan/Vehicle.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + abstract class Vehicle + { + public abstract void CarryPassange(); + } +} -- Gitee From ccbce361471805a5f8e4d043bd8c4b950b485522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=AD=9D=E6=B6=B5?= <97312789@qq.com> Date: Tue, 25 May 2021 17:38:50 +0800 Subject: [PATCH 2/2] 1 --- .../Car/BatCar.cs" | 25 +++++++++++ .../Car/Car.cs" | 20 +++++++++ .../Car/IFlyable.cs" | 13 ++++++ .../Car/OneCar.cs" | 20 +++++++++ .../Car/Program.cs" | 21 ++++++++++ .../Computer/Computer.cs" | 41 +++++++++++++++++++ .../Computer/Disk.cs" | 18 ++++++++ .../Computer/IUSB.cs" | 14 +++++++ .../Computer/MobileDisk.cs" | 26 ++++++++++++ .../Computer/Program.cs" | 22 ++++++++++ .../Computer/UDisk.cs" | 25 +++++++++++ 11 files changed, 245 insertions(+) create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/BatCar.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/Car.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/IFlyable.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/OneCar.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/Program.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/Computer.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/Disk.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/IUSB.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/MobileDisk.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/Program.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/UDisk.cs" diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/BatCar.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/BatCar.cs" new file mode 100644 index 0000000..a635b44 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/BatCar.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo525_4 +{ + class BatCar : Car, IFlyable + { + public BatCar(string brand) : base(brand) + { + } + + public void Fly() + { + Console.WriteLine("{0}车在Fly", Brand); + } + + public override void Run() + { + Console.WriteLine("{0}车在Run",Brand); + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/Car.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/Car.cs" new file mode 100644 index 0000000..f9b67d7 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/Car.cs" @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo525_4 +{ + abstract class Car + { + public string Brand { get; set; } + + public Car(string brand) + { + Brand = brand; + } + + public abstract void Run(); + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/IFlyable.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/IFlyable.cs" new file mode 100644 index 0000000..fd0dd12 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/IFlyable.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo525_4 +{ + interface IFlyable + { + void Fly(); + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/OneCar.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/OneCar.cs" new file mode 100644 index 0000000..d91c1c1 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/OneCar.cs" @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo525_4 +{ + class OneCar : Car + { + public OneCar(string brand) : base(brand) + { + } + + public override void Run() + { + Console.WriteLine("{0}车在Run", Brand); + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/Program.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/Program.cs" new file mode 100644 index 0000000..49a7957 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Car/Program.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo525_4 +{ + class Program + { + static void Main(string[] args) + { + OneCar oneCar = new OneCar("一台"); + oneCar.Run(); + + BatCar bat = new BatCar("一台蝙蝠"); + bat.Run(); + bat.Fly(); + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/Computer.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/Computer.cs" new file mode 100644 index 0000000..3ab57c1 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/Computer.cs" @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo525_3 +{ + class Computer + { + private string brand; + private IUSB usb1; + private IUSB usb2; + + public string Brand { get => brand; set => brand = value; } + internal IUSB Usb1 { get => usb1; set => usb1 = value; } + internal IUSB Usb2 { get => usb2; set => usb2 = value; } + + public Computer(string brand, IUSB usb1, IUSB usb2) + { + Brand = brand; + Usb1 = usb1; + Usb2 = usb2; + } + + public void Open() { + Console.WriteLine("{0}电脑启动...",brand); + } + public void Read() { + this.Usb1.Read(); + this.Usb2.Read(); + } + public void Write() { + this.Usb1.Write(); + this.Usb2.Write(); + } + public void Close() { + Console.WriteLine("{0}电脑关闭...",brand); + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/Disk.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/Disk.cs" new file mode 100644 index 0000000..3ab01fa --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/Disk.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo525_3 +{ + class Disk + { + private string brand; + public string Brand { get => brand; set => brand = value; } + public Disk(string brand) + { + Brand = brand; + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/IUSB.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/IUSB.cs" new file mode 100644 index 0000000..748c3eb --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/IUSB.cs" @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo525_3 +{ + interface IUSB + { + void Read(); + void Write(); + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/MobileDisk.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/MobileDisk.cs" new file mode 100644 index 0000000..88af4e3 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/MobileDisk.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo525_3 +{ + class MobileDisk : Disk, IUSB + { + public MobileDisk(string brand) : base(brand) + { + + } + + public void Read() + { + Console.WriteLine("{0}移动硬盘读取中....",Brand); + } + + public void Write() + { + Console.WriteLine("{0}移动硬盘写出中....", Brand); + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/Program.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/Program.cs" new file mode 100644 index 0000000..5dd871b --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/Program.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo525_3 +{ + class Program + { + static void Main(string[] args) + { + UDisk uDisk = new UDisk("很能存"); + MobileDisk mobileDisk = new MobileDisk("很不能存"); + Computer computer = new Computer("一台",uDisk,mobileDisk); + computer.Open(); + computer.Read(); + computer.Write(); + computer.Close(); + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/UDisk.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/UDisk.cs" new file mode 100644 index 0000000..966072c --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Computer/UDisk.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo525_3 +{ + class UDisk : Disk, IUSB + { + public UDisk(string brand) : base(brand) + { + } + + public void Read() + { + Console.WriteLine("{0}U盘读取中....",Brand); + } + + public void Write() + { + Console.WriteLine("{0}U盘写出中....", Brand); + } + } +} -- Gitee