文件名称:Weapon
- 所属分类:
- C#编程
- 资源属性:
- [Windows] [Visual.Net] [源码]
- 上传时间:
- 2012-11-26
- 文件大小:
- 32kb
- 下载次数:
- 0次
- 提 供 者:
- liu****
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
1)、定义一个抽象类Weapon,该抽象类有两个抽象方法attack(),move():这两个方法分别表示武器的攻击方式和移动方式。
(2)、定义3个类:Tank,Flighter,WarShip都继承自Weapon,分别用不同的方式实现Weapon
类中的抽象方法。
(3)、写一个类Army,代表一支军队,这个类有一个属性是Weapon数组w(用来存储该军队所拥有的所有武器);该类还提供一个构造方法,在构造方法里通过传一个int类型的参数来限定该类所能拥有的最大武器数量,并用这一大小来初始化数组w。该类还提供一个方法addWeapon(Weapon wa),表示把参数wa所代表的武器加入到数组w中。在这个类中还定义两个方法attackAll()和moveAll(),让w数组中的所有武器攻击和移动。
(4)、写一个主方法去测试以上程序。
-1), defines an abstract class Weapon, the abstract class has two abstract methods attack (), move (): These two methods represent the weapons attacks and moves.
(2), defines three classes: Tank, Flighter, WarShip are inherited from the Weapon, respectively, in different ways to achieve Weapon
Class abstract methods.
(3), write a class Army, on behalf of an army, this class has a property is an array of Weapon w (used to store all of the weapons owned by the armed forces) class provides a constructor in the constructor through the mass a parameter of type int to limit the class can have the maximum number of weapons, and to initialize the array with the size of the w. The class also provides a method addWeapon (Weapon wa), that represent the parameters wa added to the array w of weapons. In this class also defines two methods attackAll () and moveAll (), let w array and move all the weapons to attack.
(4), write a main method to test the above procedure.
(2)、定义3个类:Tank,Flighter,WarShip都继承自Weapon,分别用不同的方式实现Weapon
类中的抽象方法。
(3)、写一个类Army,代表一支军队,这个类有一个属性是Weapon数组w(用来存储该军队所拥有的所有武器);该类还提供一个构造方法,在构造方法里通过传一个int类型的参数来限定该类所能拥有的最大武器数量,并用这一大小来初始化数组w。该类还提供一个方法addWeapon(Weapon wa),表示把参数wa所代表的武器加入到数组w中。在这个类中还定义两个方法attackAll()和moveAll(),让w数组中的所有武器攻击和移动。
(4)、写一个主方法去测试以上程序。
-1), defines an abstract class Weapon, the abstract class has two abstract methods attack (), move (): These two methods represent the weapons attacks and moves.
(2), defines three classes: Tank, Flighter, WarShip are inherited from the Weapon, respectively, in different ways to achieve Weapon
Class abstract methods.
(3), write a class Army, on behalf of an army, this class has a property is an array of Weapon w (used to store all of the weapons owned by the armed forces) class provides a constructor in the constructor through the mass a parameter of type int to limit the class can have the maximum number of weapons, and to initialize the array with the size of the w. The class also provides a method addWeapon (Weapon wa), that represent the parameters wa added to the array w of weapons. In this class also defines two methods attackAll () and moveAll (), let w array and move all the weapons to attack.
(4), write a main method to test the above procedure.
(系统自动生成,下载前可以参看下载内容)
下载文件列表
抽象类Weapon
............\_4
............\_4.sln
............\_4.suo
............\..\Army.cs
............\..\bin
............\..\...\Debug
............\..\...\.....\_4.exe
............\..\...\.....\_4.pdb
............\..\...\.....\_4.vshost.exe
............\..\...\.....\_4.vshost.exe.manifest
............\..\ClassDiagram1.cd
............\..\ClassDiagram2.cd
............\..\Flighter.cs
............\..\obj
............\..\...\Debug
............\..\...\.....\Refactor
............\..\...\.....\TempPE
............\..\...\.....\_4.csproj.FileListAbsolute.txt
............\..\...\.....\_4.exe
............\..\...\.....\_4.pdb
............\..\Program.cs
............\..\Properties
............\..\..........\AssemblyInfo.cs
............\..\Tank.cs
............\..\WarShip.cs
............\..\Weapon.cs
............\..\_4.csproj
............\_4
............\_4.sln
............\_4.suo
............\..\Army.cs
............\..\bin
............\..\...\Debug
............\..\...\.....\_4.exe
............\..\...\.....\_4.pdb
............\..\...\.....\_4.vshost.exe
............\..\...\.....\_4.vshost.exe.manifest
............\..\ClassDiagram1.cd
............\..\ClassDiagram2.cd
............\..\Flighter.cs
............\..\obj
............\..\...\Debug
............\..\...\.....\Refactor
............\..\...\.....\TempPE
............\..\...\.....\_4.csproj.FileListAbsolute.txt
............\..\...\.....\_4.exe
............\..\...\.....\_4.pdb
............\..\Program.cs
............\..\Properties
............\..\..........\AssemblyInfo.cs
............\..\Tank.cs
............\..\WarShip.cs
............\..\Weapon.cs
............\..\_4.csproj