Created for object-oriented learning. I imagined the assembly of Strike Gundam and Strike Dagger, and created it with the common features of each in mind.
It was created by the following procedure.
Create an ale, sword, and launcher in the form of an interface, and describe each armament as follows.
Striker.java
package practice;
public interface Striker {
String[] arrayAile = {"57mm high energy beam rifle", "Beam saber", "Anti-beam shield"};
String[] arraySword = {"15.78m anti-ship sword "Schwert Geber"", "Beam Boomerang "Midas Messer"", "Rocket anchor "Panzer Eisen""};
String[] arrayLauncher = {"320mm ultra-high impulse cannon "Agni"", "120mm anti-ship Vulcan cannon", "350mm gun launcher"};
}
Strike Gundam and Strike Dagger use the X100 series frame as the basic skeleton. Another feature is the striker pack system. Describe these features in X100frame.java as follows.
X100frame.java
package practice;
//Since it is assumed that it will be inherited, it is abstract.
public abstract class X100frame {
private String name = "";
private String type = "X100 series frame";
private String feature = "Striker pack system";
public X100frame(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public String getType() {
return this.type;
}
public String getFeature() {
return this.feature;
}
public void list() {
System.out.println("Armed list:");
System.out.println("-------------------------");
}
//Since it will be overridden on the subclass side, write an empty method
public abstract void printData();
public abstract void printDataPersonal();
public abstract void printDataAile();
public abstract void printDataSword();
public abstract void printDataLauncher();
}
Create Strike Gundam as STRIKE class and Strike Dagger as DAGGER class. At that time, inherit the X100frame class so that the three interfaces created in step 1 can also be used.
STRIKE.java
package practice;
//Inherit the X100frame class and enable the interface Striker
public class STRIKE extends X100frame implements Striker {
public STRIKE() {super("Strike Gundam"); }
//Features of bare strike only
private String Model = "GAT-X105";
private String Armor = "Phase shift armor";
private double height = 17.72;
private double weight = 64.80;
private String WEAPON[] = {"Egerstern", "Armor Schneider"};
//Method to output the features of only the plain strike
@Override
public void printData() {
System.out.println("Mobile suit name:" + this.getName());
System.out.println("Model number:" + this.Model);
//Frames and features inherit from the X100frame class
System.out.println("flame:" + this.getType());
System.out.println("Feature:" + this.getFeature());
System.out.println("Armor:" + this.Armor);
System.out.println("Overall height:" + this.height + "m");
System.out.println("weight:" + this.weight + "t");
System.out.println();
}
@Override
public void printDataPersonal() {
for(int a = 0; a < WEAPON.length; a++ ) {
System.out.print(WEAPON[a] + " ");
}
System.out.println();
System.out.println("------------");
}
//Outputs armament when equipped with a striker pack
@Override
public void printDataAile() {
for(int a = 0; a < arrayAile.length; a++ ) {
System.out.print(arrayAile[a] + " ");
}
System.out.println();
System.out.println("------------");
}
@Override
public void printDataSword() {
for(int a = 0; a < arraySword.length; a++ ) {
System.out.print(arraySword[a] + " ");
}
System.out.println();
System.out.println("------------");
}
@Override
public void printDataLauncher() {
for(int a = 0; a < arrayLauncher.length; a++ ) {
System.out.print(arrayLauncher[a] + " ");
}
System.out.println();
System.out.println("------------");
}
}
Strike Gundam
DAGGER.java
package practice;
//Inherit the X100frame class and enable the interface Striker
public class DAGGER extends X100frame implements Striker {
public DAGGER() {super("Strike Dagger"); }
//Features of the bare strike dagger only
private String Model = "GAT-01A1";
private String Armor = "Laminated armor (body only)";
private double height = 18.00;
private double weight = 57.05;
private String WEAPON[] = {"Egerstern", "52mm cannon pod", "Beam carbine", "12.5mm anti-personnel machine gun x 2"};
//Method to output the features of the elementary strike dagger only
@Override
public void printData() {
System.out.println("Mobile suit name:" + this.getName());
System.out.println("Model number:" + this.Model);
//Frames and features inherit from the X100frame class
System.out.println("flame:" + this.getType());
System.out.println("Feature:" + this.getFeature());
System.out.println("Armor:" + this.Armor);
System.out.println("Overall height:" + this.height + "m");
System.out.println("weight:" + this.weight + "t");
System.out.println();
}
@Override
public void printDataPersonal() {
for(int a = 0; a < WEAPON.length; a++ ) {
System.out.print(WEAPON[a] + " ");
}
System.out.println();
System.out.println("------------");
}
//Outputs armament when equipped with a striker pack
@Override
public void printDataAile() {
for(int a = 0; a < arrayAile.length; a++ ) {
System.out.print(arrayAile[a] + " ");
}
System.out.println();
System.out.println("------------");
}
@Override
public void printDataSword() {
for(int a = 0; a < arraySword.length; a++ ) {
System.out.print(arraySword[a] + " ");
}
System.out.println();
System.out.println("------------");
}
@Override
public void printDataLauncher() {
for(int a = 0; a < arrayLauncher.length; a++ ) {
System.out.print(arrayLauncher[a] + " ");
}
System.out.println();
System.out.println("------------");
}
}
Strike Dagger
Create an instance and call each method.
Factory.java
package practice;
public class Factory {
public static void main(String[] args) {
STRIKE s = new STRIKE();
DAGGER d = new DAGGER();
s.printData();
s.list();
s.printDataPersonal();
s.printDataAile();
s.printDataSword();
s.printDataLauncher();
System.out.println();
d.printData();
d.list();
d.printDataPersonal();
d.printDataAile();
d.printDataSword();
d.printDataLauncher();
}
}
It was output like this.
Mobile suit name: Strike Gundam
Model number: GAT-X105
Frame: X100 series frame
Features: Striker pack system
Armor: Phase shift armor
Overall height: 17.72m
Weight: 64.8t
Armed list:
-------------------------
Egerstern Armor Schneider
------------
57mm high energy beam rifle beam saber vs beam shield
------------
15.78m anti-ship sword "Schwert Geber" Beam boomeran "Midas Messer" Rocket anchor "Panzer Eisen"
------------
320mm ultra-high impulse gun "Agni" 120mm anti-ship Vulcan gun 350mm gun launcher
------------
Mobile suit name: Strike Dagger
Model number: GAT-01A1
Frame: X100 series frame
Features: Striker pack system
Armor: Laminated armor (body only)
Overall height: 18.0m
Weight: 57.05t
Armed list:
-------------------------
Egerstern 52mm Cannon Pod Beam Carbine 12.5mm anti-personnel machine gun x 2
------------
57mm high energy beam rifle beam saber vs beam shield
------------
15.78m anti-ship sword "Schwert Geber" Beam boomeran "Midas Messer" Rocket anchor "Panzer Eisen"
------------
320mm ultra-high impulse gun "Agni" 120mm anti-ship Vulcan gun 350mm gun launcher
------------
That is all.
Recommended Posts