Examples of Warship


Examples of megamek.common.Warship

        dataFile = bb;
    }

    public Entity getEntity() throws EntityLoadingException {

        Warship a = new Warship();

        if (!dataFile.exists("Name")) {
            throw new EntityLoadingException("Could not find name block.");
        }
        a.setChassis(dataFile.getDataAsString("Name")[0]);
        if (dataFile.exists("Model") && dataFile.getDataAsString("Model")[0] != null) {
            a.setModel(dataFile.getDataAsString("Model")[0]);
        } else {
            a.setModel("");
        }

        if (dataFile.exists("source")) {
            a.setSource(dataFile.getDataAsString("source")[0]);
        }

        if (!dataFile.exists("year")) {
            throw new EntityLoadingException("Could not find year block.");
        }
        a.setYear(dataFile.getDataAsInt("year")[0]);

        setTechLevel(a);

        if (!dataFile.exists("tonnage")) {
            throw new EntityLoadingException("Could not find weight block.");
        }
        a.setWeight(dataFile.getDataAsFloat("tonnage")[0]);

        if (!dataFile.exists("crew")) {
            throw new EntityLoadingException("Could not find crew block.");
        }
        a.setNCrew(dataFile.getDataAsInt("crew")[0]);

        if (!dataFile.exists("passengers")) {
            throw new EntityLoadingException("Could not find passenger block.");
        }
        a.setNPassenger(dataFile.getDataAsInt("passengers")[0]);

        if (!dataFile.exists("life_boat")) {
            throw new EntityLoadingException("Could not find life boat block.");
        }
        a.setLifeBoats(dataFile.getDataAsInt("life_boat")[0]);

        if (!dataFile.exists("escape_pod")) {
            throw new EntityLoadingException("Could not find escape pod block.");
        }
        a.setEscapePods(dataFile.getDataAsInt("escape_pod")[0]);

        // get a movement mode - lets try Aerodyne
        int nMotion = 16;
        a.setMovementMode(nMotion);

        // figure out structural integrity
        if (!dataFile.exists("structural_integrity")) {
            throw new EntityLoadingException("Could not find structual integrity block.");
        }
        a.set0SI(dataFile.getDataAsInt("structural_integrity")[0]);

        // figure out heat
        if (!dataFile.exists("heatsinks")) {
            throw new EntityLoadingException("Could not find weight block.");
        }
        a.setHeatSinks(dataFile.getDataAsInt("heatsinks")[0]);
        if (!dataFile.exists("sink_type")) {
            throw new EntityLoadingException("Could not find weight block.");
        }
        a.setHeatType(dataFile.getDataAsInt("sink_type")[0]);

        // figure out fuel
        if (!dataFile.exists("fuel")) {
            throw new EntityLoadingException("Could not find fuel block.");
        }
        a.setFuel(dataFile.getDataAsInt("fuel")[0]);

        if (!dataFile.exists("SafeThrust")) {
            throw new EntityLoadingException("Could not find Safe Thrust block.");
        }
        a.setOriginalWalkMP(dataFile.getDataAsInt("SafeThrust")[0]);

        a.setEngine(new Engine(400, 0, 0));

        if (dataFile.exists("lithium-fusion")) {
            a.setLF(true);
        }

        if (dataFile.exists("hpg")) {
            a.setHPG(true);
        }

        // grav decks
        if (dataFile.exists("grav_deck")) {
            a.setGravDeck(dataFile.getDataAsInt("grav_deck")[0]);
        }
        if (dataFile.exists("grav_deck_large")) {
            a.setGravDeckLarge(dataFile.getDataAsInt("grav_deck_large")[0]);
        }
        if (dataFile.exists("grav_deck_huge")) {
            a.setGravDeckHuge(dataFile.getDataAsInt("grav_deck_huge")[0]);
        }

        if (dataFile.exists("armor_type")) {
            a.setArmorType(dataFile.getDataAsInt("armor_type")[0]);
        }
        if (dataFile.exists("armor_tech")) {
            a.setArmorTechLevel(dataFile.getDataAsInt("armor_tech")[0]);
        }
        if (dataFile.exists("internal_type")) {
            a.setStructureType(dataFile.getDataAsInt("internal_type")[0]);
        }

        if (!dataFile.exists("armor")) {
            throw new EntityLoadingException("Could not find armor block.");
        }

        int[] armor = dataFile.getDataAsInt("armor");

        if (armor.length != 6) {
            throw new EntityLoadingException("Incorrect armor array length");
        }

        a.initializeArmor(armor[BLKWarshipFile.NOSE], Warship.LOC_NOSE);
        a.initializeArmor(armor[BLKWarshipFile.FLS], Warship.LOC_FLS);
        a.initializeArmor(armor[BLKWarshipFile.FRS], Warship.LOC_FRS);
        a.initializeArmor(armor[BLKWarshipFile.ALS], Warship.LOC_ALS);
        a.initializeArmor(armor[BLKWarshipFile.ARS], Warship.LOC_ARS);
        a.initializeArmor(armor[BLKWarshipFile.AFT], Warship.LOC_AFT);
        a.initializeArmor(0, Warship.LOC_LBS);
        a.initializeArmor(0, Warship.LOC_RBS);

        a.autoSetInternal();
        a.autoSetThresh();
        a.initializeKFIntegrity();
        a.initializeSailIntegrity();

        loadEquipment(a, "Nose", Warship.LOC_NOSE);
        loadEquipment(a, "Front Right Side", Warship.LOC_FRS);
        loadEquipment(a, "Front Left Side", Warship.LOC_FLS);
        loadEquipment(a, "Aft Left Side", Warship.LOC_ALS);
        loadEquipment(a, "Aft Right Side", Warship.LOC_ARS);
        loadEquipment(a, "Aft", Warship.LOC_AFT);
        // for now put all broadside mounted weapons in the front location
        // TODO: turn broadsides into a real unhittable location
        loadEquipment(a, "Left Broadside", Warship.LOC_LBS);
        loadEquipment(a, "Right Broadside", Warship.LOC_RBS);

        // get the bays on this jumpship
        if (dataFile.exists("transporters")) {
            String[] transporters = dataFile.getDataAsString("transporters");
            // Walk the array of transporters.
            for (String transporter : transporters) {
                if (transporter.startsWith("SmallCraftBay:", 0)) {
                    String numbers = transporter.substring(14);
                    String temp[] = numbers.split(":");
                    int size = Integer.parseInt(temp[0]);
                    int doors = Integer.parseInt(temp[1]);
                    a.addTransporter(new SmallCraftBay(size, doors));
                } else if (transporter.startsWith("ASFBay:", 0)) {
                    String numbers = transporter.substring(7);
                    String temp[] = numbers.split(":");
                    int size = Integer.parseInt(temp[0]);
                    int doors = Integer.parseInt(temp[1]);
                    a.addTransporter(new ASFBay(size, doors));
                } else if (transporter.startsWith("MechBay:", 0)) {
                    String numbers = transporter.substring(8);
                    String temp[] = numbers.split(":");
                    int size = Integer.parseInt(temp[0]);
                    int doors = Integer.parseInt(temp[1]);
                    a.addTransporter(new MechBay(size, doors));
                } else if (transporter.startsWith("LightVehicleBay:", 0)) {
                    String numbers = transporter.substring(16);
                    String temp[] = numbers.split(":");
                    int size = Integer.parseInt(temp[0]);
                    int doors = Integer.parseInt(temp[1]);
                    a.addTransporter(new LightVehicleBay(size, doors));
                } else if (transporter.startsWith("HeavyVehicleBay:", 0)) {
                    String numbers = transporter.substring(16);
                    String temp[] = numbers.split(":");
                    int size = Integer.parseInt(temp[0]);
                    int doors = Integer.parseInt(temp[1]);
                    a.addTransporter(new HeavyVehicleBay(size, doors));
                } else if (transporter.startsWith("InfantryBay:", 0)) {
                    String numbers = transporter.substring(12);
                    String temp[] = numbers.split(":");
                    int size = Integer.parseInt(temp[0]);
                    int doors = Integer.parseInt(temp[1]);
                    a.addTransporter(new InfantryBay(size, doors));
                } else if (transporter.startsWith("BattleArmorBay:", 0)) {
                    String numbers = transporter.substring(15);
                    String temp[] = numbers.split(":");
                    int size = Integer.parseInt(temp[0]);
                    int doors = Integer.parseInt(temp[1]);
                    a.addTransporter(new BattleArmorBay(size, doors));
                } else if (transporter.startsWith("CargoBay:", 0)) {
                    String numbers = transporter.substring(9);
                    String temp[] = numbers.split(":");
                    int size = Integer.parseInt(temp[0]);
                    int doors = Integer.parseInt(temp[1]);
                    a.addTransporter(new CargoBay(size, doors));
                }
            }
        }

        // get docking collars
        if (!dataFile.exists("docking_collar")) {
            throw new EntityLoadingException("Could not find docking collar block.");
        }
        int docks = dataFile.getDataAsInt("docking_collar")[0];
        while (docks > 0) {
            a.addTransporter(new DockingCollar(1));
            docks--;
        }

        return a;
    }
View Full Code Here

Examples of megamek.common.Warship

        return a;
    }

    @Override
    protected void loadEquipment(Entity en, String sName, int nLoc) throws EntityLoadingException {
        Warship a = (Warship) en;
        String[] saEquip = dataFile.getDataAsString(sName + " Equipment");
        if (saEquip == null) {
            return;
        }

        // prefix is "Clan " or "IS "
        String prefix;
        if (a.getTechLevel() == TechConstants.T_CLAN_TW) {
            prefix = "Clan ";
        } else {
            prefix = "IS ";
        }

        boolean rearMount = false;
        int nAmmo = 1;
        // set up a new weapons bay mount
        Mounted bayMount = null;
        // set up a new bay type
        boolean newBay = false;
        boolean subCap = false;
        int bayDamage = 0;
        int nBay = 1;
        if (saEquip[0] != null) {
            for (String element : saEquip) {
                rearMount = false;
                nAmmo = 1;
                newBay = false;
                subCap = false;
                String equipName = element.trim();

                // I will need to deal with rear-mounted bays on Dropships
                if (equipName.startsWith("(R) ")) {
                    rearMount = true;
                    equipName = equipName.substring(4);
                }

                if (equipName.startsWith("(B) ")) {
                    newBay = true;
                    equipName = equipName.substring(4);
                }

                if (equipName.startsWith("(SC) ")) {
                    newBay = true;
                    subCap = true;
                    equipName = equipName.substring(5);
                }

                // check for ammo loadouts
                if (equipName.contains(":") && equipName.contains("Ammo")) {
                    // then split by the :
                    String[] temp;
                    temp = equipName.split(":");
                    equipName = temp[0];
                    if (temp[1] != null) {
                        nAmmo = Integer.parseInt(temp[1]);
                    }
                }

                EquipmentType etype = EquipmentType.get(equipName);

                if (etype == null) {
                    // try w/ prefix
                    etype = EquipmentType.get(prefix + equipName);
                }

                if (etype != null) {
                    // first load the equipment
                    Mounted newmount;
                    try {
                        if (nAmmo == 1) {
                            newmount = a.addEquipment(etype, nLoc, rearMount);
                        } else {
                            newmount = a.addEquipment(etype, nLoc, rearMount, nAmmo);
                        }
                    } catch (LocationFullException ex) {
                        throw new EntityLoadingException(ex.getMessage());
                    }

                    // this is where weapon bays go
                    // first, lets see if it is a weapon
                    if (newmount.getType() instanceof WeaponType) {
                        // if so then I need to find out if it is the same class
                        // as the current weapon bay
                        // If the current bay is null, then it needs to be
                        // initialized
                        WeaponType weap = (WeaponType) newmount.getType();
                        if (bayMount == null) {
                            if (subCap) {
                                try {
                                    bayMount = a.addEquipment(WeaponType.getSubCapBayType(weap.getAtClass()), nLoc, rearMount);
                                    newBay = false;
                                } catch (LocationFullException ex) {
                                    throw new EntityLoadingException(ex.getMessage());
                                }
                            } else {
                                try {
                                    bayMount = a.addEquipment(WeaponType.getBayType(weap.getAtClass()), nLoc, rearMount);
                                    newBay = false;
                                } catch (LocationFullException ex) {
                                    throw new EntityLoadingException(ex.getMessage());
                                }
                            }
                        }

                        int damage = weap.getRoundShortAV();
                        if (weap.isCapital()) {
                            damage *= 10;
                        }
                        if (!newBay && (bayDamage + damage) <= 700 && bayMount.isRearMounted() == rearMount && weap.getAtClass() == ((WeaponType) bayMount.getType()).getAtClass() && !(((WeaponType) bayMount.getType()).isSubCapital() && !weap.isSubCapital())) {
                            // then we should add this weapon to the current bay
                            bayMount.addWeaponToBay(a.getEquipmentNum(newmount));
                            bayDamage += damage;
                        } else {
                            if (subCap) {
                                try {
                                    bayMount = a.addEquipment(WeaponType.getSubCapBayType(weap.getAtClass()), nLoc, rearMount);
                                } catch (LocationFullException ex) {
                                    throw new EntityLoadingException(ex.getMessage());
                                }
                            } else {
                                try {
                                    bayMount = a.addEquipment(WeaponType.getBayType(weap.getAtClass()), nLoc, rearMount);
                                } catch (LocationFullException ex) {
                                    throw new EntityLoadingException(ex.getMessage());
                                }
                            }
                            bayMount.addWeaponToBay(a.getEquipmentNum(newmount));
                            // reset bay damage
                            bayDamage = damage;
                            nBay++;
                        }
                    }
                    // ammo should also get loaded into the bay
                    if (newmount.getType() instanceof AmmoType) {
                        bayMount.addAmmoToBay(a.getEquipmentNum(newmount));
                    }
                } else if (equipName != "0") {
                    a.addFailedEquipment(equipName);
                }
            }
        }
    }
View Full Code Here

Examples of warships.Warship

    System.out.println();
       
    //a) create various objects from  the 6 classes
   
    //create three warships
    Warship warship1 = new Warship(); //using default constructor
    Warship warship2 = new Warship(200, 20000, 15, "USA" ); //using parametrized constructor
    Warship warship3 = new Warship(200, 20000, 15, "USA" ); //using parametrized constructor
    //create three Submarines
    Submarine submarine1 = new Submarine(); //using default constructor
    Submarine submarine2 = new Submarine(250, 21000, 13, "India", PowerSource.NUCLEAR, 2, "Periscope"); //using parametrized constructor
    Submarine submarine3 = new Submarine(250, 21000, 13, "India", PowerSource.NUCLEAR, 2, "Periscope"); //using parametrized constructor
    Submarine submarine4 = new Submarine(260, 21000, 13, "India", PowerSource.NUCLEAR, 2, "Periscope"); //using parametrized constructor
    //create two Destroyers
    Destroyer destroyer1 = new Destroyer(); //using default constructor
    Destroyer destroyer2 = new Destroyer(300, 22000, 14, "France", AttackType.ANTIAIRCRAFT, 5,5); //using parametrized constructor
    //create three AircraftCarriers
    AircraftCarrier aircraftCarrier1 = new AircraftCarrier(); //using default constructor
    AircraftCarrier aircraftCarrier2 = new AircraftCarrier(200, 19000,14, "USA", 4, 2 ); //using parametrized constructor
    AircraftCarrier aircraftCarrier3 = new AircraftCarrier(200, 19000,14, "USA", 4, 2 ); //using parametrized constructor
    //create two AmphibiousAssaultShips
    AmphibiousAssaultShip aaShip1 = new AmphibiousAssaultShip();//using default constructor
    AmphibiousAssaultShip aaShip2 = new AmphibiousAssaultShip(210,19500,14,"India",3,3,5); //using parametrized constructor
    //create three SuperCarriers
    SuperCarrier superCarrier1 = new SuperCarrier();//using default constructor
    SuperCarrier superCarrier2 = new SuperCarrier(220,18300,17,"France",2,2,5); //using parametrzed constructor
    SuperCarrier superCarrier3 = new SuperCarrier(220,18300,17,"France",2,2,5); //using parametrzed constructor
   
    System.out.println("A few differnt types of Warships were created and will be displayed below using their respectively defined toString() methods.");
    //Print the objects using the toString method
    System.out.println();
    System.out.println("\nHere are the three Warships: ");
    System.out.println(warship1);
    System.out.println(warship2);
    System.out.println(warship3);
    System.out.println("\nHere are the Four Submarines: ");
    System.out.println(submarine1);
    System.out.println(submarine2);
    System.out.println(submarine3);
    System.out.println(submarine4);
    System.out.println("\nHere are the two Destroyers: ");
    System.out.println(destroyer1);
    System.out.println(destroyer2);
    System.out.println("\nHere are the three Aircraft Carriers: ");
    System.out.println(aircraftCarrier1);
    System.out.println(aircraftCarrier2);
    System.out.println(aircraftCarrier3);
    System.out.println("\nHere are the two Amphibious Assault Ships: ");
    System.out.println(aaShip1);
    System.out.println(aaShip2);
    System.out.println("\nHere are the three Super Carriers: ");
    System.out.println(superCarrier1);
    System.out.println(superCarrier2);
    System.out.println(superCarrier3);
   
    System.out.println("\nLet's test some of these objects for equality!");
    //testing objects for equality
    if(warship1.equals(warship2)){
      System.out.println("Warship1 is the same as Warship2");
    }else {
      System.out.println("Warship1 is not the same as Warship2");
    }
    if(warship2.equals(warship3)){
      System.out.println("Warship2 is the same as Warship3");
    }else {
      System.out.println("Warship2 is not the same as Warship3");
    }
    if(submarine1.equals(submarine3)){
      System.out.println("Submarine1 is the same as Submarine3");
    }else {
      System.out.println("Submarine1 is not the same as Submarine3");
    }
    if(submarine2.equals(submarine3)){
      System.out.println("Submarine2 is the same as Submarine3");
    }else {
      System.out.println("Submarine2 is not the same as Submarine3");
    }if(submarine1.equals(warship3)){
      System.out.println("Submarine1 is the same as Warship3");
    }else {
      System.out.println("Submarine1 is not the same as Warship3");
    }
    if(destroyer1.equals(destroyer2)){
      System.out.println("Destroyer1 is the same as Destroyer2");
    }else {
      System.out.println("Destroyer1 is not the same as Destroyer2");
    }
    if(aircraftCarrier1.equals(aircraftCarrier2)){
      System.out.println("Aircraft Carrier1 is the same as Aircraft Carrier2");
    }else {
      System.out.println("Aircraft Carrier1 is not the same as Aircraft Carrier2");
    }
    if(aaShip1.equals(aaShip2)){
      System.out.println("Amphibious Assault Ship1 is the same as Amphibious Assault Ship2");
    }else {
      System.out.println("Amphibious Assault Ship1 is not the same as Amphibious Assault Ship2");
    }
    if(submarine3.equals(submarine4)){
      System.out.println("Submarine3 is the same as Submarine4");
    }else {
      System.out.println("Submarine3 is not the same as Submarine4");
    }
   
    //part b) creating an array of 10 warships
    Warship[] navalForce = new Warship[10];
    navalForce[0] = warship1;
    navalForce[1] = warship2;
    navalForce[2] = warship3;
    navalForce[3] = destroyer1;
    navalForce[4] = submarine1;
    navalForce[5] = submarine2;
    navalForce[6] = submarine3;
    navalForce[7] = aircraftCarrier1;
    navalForce[8] = aaShip1;
    navalForce[9] = superCarrier2;
   
    //filling the array with objects
    navalForce[0] = new Warship(); //using default constructor
    navalForce[1] = new Warship(199, 20200, 13, "INDIA" ); //using parametrized constructor
    navalForce[2] = new Warship(201, 22000, 15, "RUSSIA" ); //using parametrized constructor
    navalForce[3] = new Destroyer(300, 22300, 12, "France", AttackType.ANTIAIRCRAFT, 5,5); //using parametrized constructor
    navalForce[4] = new Submarine(150, 21000, 13, "India", PowerSource.NUCLEAR, 2, "Periscope"); //using parametrized constructor
    navalForce[5] = new Submarine(450, 27000, 19, "USA", PowerSource.NUCLEAR, 2, "Periscope"); //using parametrized constructor
    navalForce[6] = new Submarine(350, 21000, 12, "UK", PowerSource.NUCLEAR, 2, "Periscope"); //using parametrized constructor
    navalForce[7] = new AircraftCarrier(200, 19000,14, "USA", 4, 2 ); //using parametrized constructor
View Full Code Here

Examples of warships.Warship

    System.out.println();
 
    //a) create various objects from  the 6 classes
   
    //create three warships
    Warship warship1 = new Warship(); //using default constructor
    Warship warship2 = new Warship(200, 20000, 15, "USA" ); //using parametrized constructor
    Warship warship3 = new Warship(200, 20000, 15, "USA" ); //using parametrized constructor
    //create three Submarines
    Submarine submarine1 = new Submarine(); //using default constructor
    Submarine submarine2 = new Submarine(250, 21000, 13, "India", PowerSource.NUCLEAR, 2, "Periscope"); //using parametrized constructor
    Submarine submarine3 = new Submarine(250, 21000, 13, "India", PowerSource.NUCLEAR, 2, "Periscope"); //using parametrized constructor
    //create two Destroyers
    Destroyer destroyer1 = new Destroyer(); //using default constructor
    Destroyer destroyer2 = new Destroyer(300, 22000, 14, "France", AttackType.ANTIAIRCRAFT, 5,5); //using parametrized constructor
    //create three AircraftCarriers
    AircraftCarrier aircraftCarrier1 = new AircraftCarrier(); //using default constructor
    AircraftCarrier aircraftCarrier2 = new AircraftCarrier(200, 19000,14, "USA", 4, 2 ); //using parametrized constructor
    AircraftCarrier aircraftCarrier3 = new AircraftCarrier(200, 19000,14, "USA", 4, 2 ); //using parametrized constructor
    //create two AmphibiousAssaultShips
    AmphibiousAssaultShip aaShip1 = new AmphibiousAssaultShip();//using default constructor
    AmphibiousAssaultShip aaShip2 = new AmphibiousAssaultShip(210,19500,14,"India",3,3,5); //using parametrized constructor
    //create three SuperCarriers
    SuperCarrier superCarrier1 = new SuperCarrier();//using default constructor
    SuperCarrier superCarrier2 = new SuperCarrier(220,18300,17,"France",2,2,5); //using parametrzed constructor
    SuperCarrier superCarrier3 = new SuperCarrier(220,18300,17,"France",2,2,5); //using parametrzed constructor
   
    System.out.println("A few types of Warships were created and will be displayed below using their respectively defined toString() methods.");
    //Print the objects using the toString method
    System.out.println("\nHere are the three Warships: ");
    System.out.println(warship1);
    System.out.println(warship2);
    System.out.println(warship3);
    System.out.println("\nHere are the three Submarines: ");
    System.out.println(submarine1);
    System.out.println(submarine2);
    System.out.println(submarine3);
    System.out.println("\nHere are the two Destroyers: ");
    System.out.println(destroyer1);
    System.out.println(destroyer2);
    System.out.println("\nHere are the three Aircraft Carriers: ");
    System.out.println(aircraftCarrier1);
    System.out.println(aircraftCarrier2);
    System.out.println(aircraftCarrier3);
    System.out.println("\nHere are the two Amphibious Assault Ships: ");
    System.out.println(aaShip1);
    System.out.println(aaShip2);
    System.out.println("\nHere are the three Super Carriers: ");
    System.out.println(superCarrier1);
    System.out.println(superCarrier2);
    System.out.println(superCarrier3);
   
    System.out.println("\nLet's test some of these objects for equality!");
    //testing objects for equality
    if(warship1.equals(warship2)){
      System.out.println("Warship1 is the same as Warship2");
    }else {
      System.out.println("Warship1 is not the same as Warship2");
    }
    if(warship2.equals(warship3)){
      System.out.println("Warship2 is the same as Warship3");
    }else {
      System.out.println("Warship2 is not the same as Warship3");
    }
    if(submarine1.equals(submarine3)){
      System.out.println("Submarine1 is the same as Submarine3");
    }else {
      System.out.println("Submarine1 is not the same as Submarine3");
    }
    if(submarine2.equals(submarine3)){
      System.out.println("Submarine2 is the same as Submarine3");
    }else {
      System.out.println("Submarine2 is not the same as Submarine3");
    }if(submarine1.equals(warship3)){
      System.out.println("Submarine1 is the same as Warship3");
    }else {
      System.out.println("Submarine1 is not the same as Warship3");
    }
    if(destroyer1.equals(destroyer2)){
      System.out.println("Destroyer1 is the same as Destroyer2");
    }else {
      System.out.println("Destroyer1 is not the same as Destroyer2");
    }
    if(aircraftCarrier1.equals(aircraftCarrier2)){
      System.out.println("Aircraft Carrier1 is the same as Aircraft Carrier2");
    }else {
      System.out.println("Aircraft Carrier1 is not the same as Aircraft Carrier2");
    }
    if(aaShip1.equals(aaShip2)){
      System.out.println("Amphibious Assault Ship1 is the same as Amphibious Assault Ship2");
    }else {
      System.out.println("Amphibious Assault Ship1 is not the same as Amphibious Assault Ship2");
    }
   
    //creating an array of 10 warships
    Warship[] navalForce = new Warship[10];
    navalForce[0] = warship1;
    navalForce[1] = warship2;
    navalForce[2] = warship3;
    navalForce[3] = destroyer1;
    navalForce[4] = submarine1;
    navalForce[5] = submarine2;
    navalForce[6] = submarine3;
    navalForce[7] = aircraftCarrier1;
    navalForce[8] = aaShip1;
    navalForce[9] = superCarrier2;
   
    //filling the array with objects
    navalForce[0] = new Warship(); //using default constructor
    navalForce[1] = new Warship(199, 20200, 13, "INDIA" ); //using parametrized constructor
    navalForce[2] = new Warship(201, 22000, 15, "RUSSIA" ); //using parametrized constructor
    navalForce[3] = new Destroyer(300, 22300, 12, "France", AttackType.ANTIAIRCRAFT, 5,5); //using parametrized constructor
    navalForce[4] = new Submarine(150, 21000, 13, "India", PowerSource.NUCLEAR, 2, "Periscope"); //using parametrized constructor
    navalForce[5] = new Submarine(450, 27000, 19, "USA", PowerSource.NUCLEAR, 2, "Periscope"); //using parametrized constructor
    navalForce[6] = new Submarine(350, 21000, 12, "UK", PowerSource.NUCLEAR, 2, "Periscope"); //using parametrized constructor
    navalForce[7] = new AircraftCarrier(200, 19000,14, "USA", 4, 2 ); //using parametrized constructor
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.