Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Factory
- package Base_Package;
- import Buildings.Hatchery;
- import Buildings.HydraliskDen;
- import Buildings.SpawningPool;
- import Buildings.Spire;
- import java.util.Scanner;
- public class Factory
- {
- static Hatchery ObHatchery = null;
- static SpawningPool ObSpawningPool = null;
- static HydraliskDen ObHydraliskDen = null;
- static Spire ObSpire = null;
- public static void main(String[] args)
- {
- if(ObHatchery == null)
- {
- ObHatchery = new Hatchery();
- }
- boolean EndProg = false;
- Scanner Input = new Scanner(System.in);
- System.out.println("StarCraft 2 Zergs");
- do {
- menu();
- int BuildingOption = Input.nextInt();
- switch (BuildingOption) {
- case 1:
- ObHatchery.Build();
- break;
- case 2:
- if(ObSpawningPool == null)
- {
- System.out.println("Utworzono Niecke Rozrodcza.Mozesz teraz powijac Zerglingi!");
- ObSpawningPool = new SpawningPool();
- ObHatchery.IsAlreadyBuild(1);
- }
- else
- {
- ObSpawningPool.Build();
- }
- break;
- case 3:
- if(ObHydraliskDen == null)
- {
- System.out.println("Utworzono Nore Hydraliskow.Mozesz teraz powijac Hydraliski!");
- ObHydraliskDen = new HydraliskDen();
- ObHatchery.IsAlreadyBuild(2);
- }
- else
- {
- ObHydraliskDen.Build();
- }
- break;
- case 4:
- if(ObSpire == null)
- {
- System.out.println("Utworzono Iglice!");
- ObSpire = new Spire();
- }
- else
- {
- ObSpire.Build();
- }
- break;
- case 5:
- EndProg = true;
- break;
- default:
- break;
- }
- } while (!EndProg);
- Input.close();
- }
- static void menu()
- {
- System.out.println("1.Aby przejsc do mozliwosci " + ObHatchery.getName() + " - Jednostki Naziemne");
- if(ObSpawningPool == null)
- {
- System.out.println("2.Aby utworzyc Niecke Rozrodcza");
- }
- else
- {
- System.out.println("2.Aby przejsc do Niecki Rozrodczej - ulepszen Zerglingow");
- }
- if(ObHydraliskDen == null)
- {
- System.out.println("3.Aby utworzyc Nore Hydraliskow");
- }
- else
- {
- System.out.println("3.Aby przejsc do Nory Hydraliskow - ulepszen Hydraliskow");
- }
- if(ObSpire == null)
- {
- System.out.println("4.Aby utworzyc Iglice");
- }
- else
- {
- System.out.println("4.Aby przejsc do Iglicy - Jednostki Latajace");
- }
- System.out.println("5.Aby wyjsc");
- }
- }
- //IFactory
- package Base_Package;
- public interface IFactory
- {
- int getCost();
- String getName();
- }
- //IFlyingUnit
- package Base_Package;
- public interface IFlyingUnit
- {
- String getName();
- String getUnitType();
- String getArmorType();
- void SetDMGUpgrade(int NewDMGBonus);
- int GetDMGBonus();
- int GetDMG();
- }
- //IGroundUnit
- package Base_Package;
- public interface IGroundUnit
- {
- String getName();
- String getUnitType();
- String getArmorType();
- }
- //ITechnology
- package Base_Package;
- public interface ITechnology
- {
- String GetName();
- String GetCost();
- boolean GetIsReady();
- void SetIsReady(boolean Ready);
- }
- //Hatchery
- package Buildings;
- import Base_Package.IFactory;
- import Base_Package.IGroundUnit;
- import Units.Larva;
- import Units.Zergling;
- import Units.Hydralisk;
- import java.util.Scanner;
- public class Hatchery implements IFactory
- {
- String Name = "Wylegarnia";
- int Cost = 400;
- Scanner UserInput = new Scanner(System.in);
- boolean SpawningPoolBuilt = false;
- boolean HydraliskDenBuilt = false;
- boolean SpireBuilt = false;
- boolean LarvaCreated = false;
- public IGroundUnit Build()
- {
- int BuildingOption;
- int LarvaOption;
- do {
- MenuOptions();
- BuildingOption = UserInput.nextInt();
- switch(BuildingOption)
- {
- case 1:
- LarvaCreated = true;
- System.out.println("Utworzono nowego Larwy! Mozesz teraz powijac Zergi");
- return new Larva();
- case 2:
- if (LarvaCreated)
- {
- LarvaOptions();
- LarvaOption = UserInput.nextInt();
- switch(LarvaOption)
- {
- case 1:
- if(SpawningPoolBuilt)
- {
- System.out.println("Utworzono nowego Zerglinga!");
- return new Zergling();
- } else
- {
- System.out.println("Potrzebujemy zbudowac Niecke Rozrodcza.");
- }
- break;
- case 2:
- if(HydraliskDenBuilt)
- {
- System.out.println("Utworzono nowego Hydraliska!");
- return new Hydralisk();
- }
- else
- {
- System.out.println("Potrzebujemy postawic Nore Hydraliskow." );
- }
- break;
- case 3:
- {
- System.out.println("Anulowano." );
- }
- break;
- default:
- System.out.println("Podano niewlasciwy wybor." );
- throw new IllegalArgumentException();
- }
- }
- else
- {
- System.out.println("Musisz powic Larwy.");
- }
- break;
- case 3:
- if (Name.equals("Wylegarnia"))
- {
- Name = "Leze";
- }
- if (Name.equals("Leze"))
- {
- Name = "Ul";
- }
- if(Name.equals("Ul"))
- {
- System.out.println("Nie mozna ulepszyc bardziej.");
- }
- break;
- case 4:
- return null;
- default:
- System.out.println("Podano niewlasciwy wybor." );
- throw new IllegalArgumentException();
- }
- } while (BuildingOption != 4);
- return null;
- }
- private void LarvaOptions()
- {
- System.out.println("1.Aby powic Zerglinga");
- System.out.println("2.Aby powic Hydraliska");
- System.out.println("3.Aby anulowac");
- }
- private void MenuOptions()
- {
- System.out.println("1.Aby powic Larwy.");
- System.out.println("2.Aby przejsc do menu Larwy.");
- System.out.println("3.Aby ulepszyc " + Name+".");
- System.out.println("4.Aby wyjsc.");
- }
- public void IsAlreadyBuild(int WhichOne)
- {
- switch (WhichOne)
- {
- case 1:
- SpawningPoolBuilt = true;
- break;
- case 2:
- HydraliskDenBuilt = true;
- break;
- default:
- System.out.println("Cos poszlo nie tak w Hatchery Class");
- }
- }
- @Override
- public int getCost()
- {
- return Cost;
- }
- @Override
- public String getName()
- {
- return Name;
- }
- }
- //HydraliskDen
- package Buildings;
- import Base_Package.IFactory;
- import Base_Package.ITechnology;
- import Technology.GroovedSpines;
- import Technology.MuscularAugments;
- import java.util.Scanner;
- public class HydraliskDen implements IFactory
- {
- static MuscularAugments ObMuscularAugments = null;
- static GroovedSpines ObGroovedSpines = null;
- String Name = "Nora Hydraliskow";
- int Cost = 100;
- Scanner UserInput = new Scanner(System.in);
- public ITechnology Build()
- {
- int BuildingOption;
- do {
- MenuOptions();
- BuildingOption = UserInput.nextInt();
- switch(BuildingOption)
- {
- case 1:
- if(ObMuscularAugments == null)
- {
- System.out.println("Od teraz Hyraliski będą pędzić za wrogami.");
- ObMuscularAugments = new MuscularAugments();
- ObMuscularAugments.SetIsReady(true);
- }
- else
- {
- System.out.println(ObMuscularAugments.GetName() +" zostalo juz zbadany.");
- }
- break;
- case 2:
- if(ObGroovedSpines == null)
- {
- System.out.println("Od teraz Hyraliski będą szerzyć pogrom z dalszej odleglosci.");
- ObGroovedSpines = new GroovedSpines();
- ObGroovedSpines.SetIsReady(true);
- }
- else
- {
- System.out.println(ObGroovedSpines.GetName() +" zostalo juz zbadany.");
- }
- break;
- case 3:
- return null;
- default:
- System.out.println("Podano niewlasciwy wybor." );
- throw new IllegalArgumentException();
- }
- } while (BuildingOption != 3);
- return null;
- }
- private void MenuOptions()
- {
- System.out.println("1.Aby zbadac Wzmocnienie Miesni. - Zwiekszy predkosc poruszania.");
- System.out.println("2.Aby zbadac Rowkowane Kolce. - Zwiekszy zasieg ataku jednostki.");
- System.out.println("3.Aby wyjsc z Nory Hydraliskow");
- }
- @Override
- public int getCost()
- {
- return Cost;
- }
- @Override
- public String getName()
- {
- return Name;
- }
- }
- //SpawningPool
- package Buildings;
- import Base_Package.IFactory;
- import Base_Package.ITechnology;
- import Technology.AdrenalGlands;
- import Technology.MetabolicBoost;
- import java.util.Scanner;
- public class SpawningPool implements IFactory
- {
- static MetabolicBoost ObMetabolicBoost = null;
- static AdrenalGlands ObAdernalGlands = null;
- String Name = "Niecka Rozdrodcza";
- int Cost = 150;
- Scanner UserInput = new Scanner(System.in);
- public ITechnology Build()
- {
- int BuildingOption;
- do {
- MenuOptions();
- BuildingOption = UserInput.nextInt();
- switch(BuildingOption)
- {
- case 1:
- if(ObMetabolicBoost == null)
- {
- System.out.println("Od teraz Zerglingi będą pędzić za wrogami.");
- ObMetabolicBoost = new MetabolicBoost();
- ObMetabolicBoost.SetIsReady(true);
- }
- else
- {
- System.out.println("Przyspieszony metabolizm zostal juz zbadany.");
- }
- break;
- case 2:
- if(ObAdernalGlands == null)
- {
- System.out.println("Od teraz Zerglingi będą szerzyć pogrom jeszcze szybciej.");
- ObAdernalGlands = new AdrenalGlands();
- ObAdernalGlands.SetIsReady(true);
- }
- else
- {
- System.out.println("Nadrecza zostaly juz zbadane.");
- }
- break;
- case 3:
- return null;
- default:
- System.out.println("Podano niewlasciwy wybor." );
- throw new IllegalArgumentException();
- }
- } while (BuildingOption != 3);
- return null;
- }
- private void MenuOptions()
- {
- System.out.println("1.Aby zbadac przyspieszony metabolizm. - Zwiekszy predkosc poruszania");
- System.out.println("2.Aby zbadac nadrecza. - Zwiekszy predkosc zadawanych obrazen");
- System.out.println("3.Aby wyjsc z Niecki Rozrodczej");
- }
- @Override
- public int getCost()
- {
- return Cost;
- }
- @Override
- public String getName()
- {
- return Name;
- }
- }
- //Spire
- package Buildings;
- import Base_Package.IFactory;
- import Base_Package.IFlyingUnit;
- import Units.Corruptor;
- import Units.Mutalisk;
- import java.util.Scanner;
- public class Spire implements IFactory
- {
- static Mutalisk ObMutalisk = new Mutalisk();
- static Corruptor ObCorruptor = new Corruptor();
- String Name = "Iglica";
- int Cost = 200;
- Scanner UserInput = new Scanner(System.in);
- public IFlyingUnit Build()
- {
- int BuildingOption;
- do {
- MenuOptions();
- BuildingOption = UserInput.nextInt();
- switch(BuildingOption)
- {
- case 1:
- System.out.println("Utworzono nowego Mutaliska!");
- return new Mutalisk();
- case 2:
- System.out.println("Utworzono nowego Skaziciela!");
- return new Corruptor();
- case 3:
- switch(ObMutalisk.GetDMGBonus())
- {
- case 0:
- ObMutalisk.SetDMGUpgrade(1);
- ObCorruptor.SetDMGUpgrade(1);
- System.out.println("Obrazenia zostaly zwiekszone. Bonus DMG wynosi: " + ObMutalisk.GetDMGBonus());
- break;
- case 1:
- ObMutalisk.SetDMGUpgrade(2);
- ObCorruptor.SetDMGUpgrade(2);
- System.out.println("Obrazenia zostaly zwiekszone. Bonus DMG wynosi: " + ObMutalisk.GetDMGBonus());
- break;
- case 2:
- System.out.println("Ulepszenie do obrazen zostalo rozwiniete maksymalnie.");
- break;
- }
- break;
- case 4:
- return null;
- default:
- System.out.println("Podano niewlasciwy wybor." );
- throw new IllegalArgumentException();
- }
- } while (BuildingOption != 4);
- return null;
- }
- private void MenuOptions()
- {
- System.out.println("1.Aby powic Mutaliska");
- System.out.println("2.Aby powic Koruptora");
- System.out.println("3.Aby ulepszyc obrazenia jednostek latajacych");
- System.out.println("4.Aby wyjsc z Iglicy");
- }
- @Override
- public int getCost()
- {
- return Cost;
- }
- @Override
- public String getName()
- {
- return Name;
- }
- }
- //AdrenalGlands
- package Technology;
- import Base_Package.ITechnology;
- public class AdrenalGlands implements ITechnology
- {
- String Name = "Nadnercza";
- int Cost = 100;
- boolean IsReady = false;
- @Override
- public String GetName()
- {
- return Name;
- }
- @Override
- public String GetCost()
- {
- return null;
- }
- @Override
- public boolean GetIsReady()
- {
- return IsReady;
- }
- @Override
- public void SetIsReady(boolean Ready)
- {
- IsReady = Ready;
- }
- }
- //GroovedSpines
- package Technology;
- import Base_Package.ITechnology;
- public class GroovedSpines implements ITechnology
- {
- String Name = "Rowkowane Kolce";
- int Cost = 100;
- boolean IsReady = false;
- @Override
- public String GetName()
- {
- return Name;
- }
- @Override
- public String GetCost()
- {
- return null;
- }
- @Override
- public boolean GetIsReady()
- {
- return IsReady;
- }
- @Override
- public void SetIsReady(boolean Ready)
- {
- IsReady = Ready;
- }
- }
- //MetabolicBoost
- package Technology;
- import Base_Package.ITechnology;
- public class MetabolicBoost implements ITechnology
- {
- String Name = "Przyspieszony Metabolizm";
- int Cost = 100;
- boolean IsReady = false;
- @Override
- public String GetName()
- {
- return Name;
- }
- @Override
- public String GetCost()
- {
- return null;
- }
- @Override
- public boolean GetIsReady()
- {
- return IsReady;
- }
- @Override
- public void SetIsReady(boolean Ready)
- {
- IsReady = Ready;
- }
- }
- //MuscularAugments
- package Technology;
- import Base_Package.ITechnology;
- public class MuscularAugments implements ITechnology
- {
- String Name = "Wzmocnienie Miesni";
- int Cost = 100;
- boolean IsReady = false;
- @Override
- public String GetName()
- {
- return Name;
- }
- @Override
- public String GetCost()
- {
- return null;
- }
- @Override
- public boolean GetIsReady()
- {
- return IsReady;
- }
- @Override
- public void SetIsReady(boolean Ready)
- {
- IsReady = Ready;
- }
- }
- //Corruptor
- package Units;
- import Base_Package.IFlyingUnit;
- public class Corruptor implements IFlyingUnit
- {
- String Name = "Skaziciel";
- String UnitType = "Bio";
- String ArmorType = "Light";
- int DMG = 5;
- int DMGBonus = 0;
- @Override
- public String getName()
- {
- return Name;
- }
- @Override
- public String getUnitType()
- {
- return UnitType;
- }
- @Override
- public String getArmorType()
- {
- return ArmorType;
- }
- @Override
- public void SetDMGUpgrade(int NewDMGBonus)
- {
- DMGBonus = NewDMGBonus;
- }
- @Override
- public int GetDMGBonus()
- {
- return DMGBonus;
- }
- @Override
- public int GetDMG()
- {
- return DMG+DMGBonus;
- }
- }
- //Hydralisk
- package Units;
- import Base_Package.IGroundUnit;
- public class Hydralisk implements IGroundUnit
- {
- String Name = "Hydralisk";
- String UnitType = "Bio";
- String ArmorType = "Light";
- @Override
- public String getName()
- {
- return Name;
- }
- @Override
- public String getUnitType()
- {
- return UnitType;
- }
- @Override
- public String getArmorType()
- {
- return ArmorType;
- }
- }
- //Larva
- package Units;
- import Base_Package.IGroundUnit;
- public class Larva implements IGroundUnit
- {
- String Name = "Larwa";
- String UnitType = "Bio";
- String ArmorType = "Light";
- @Override
- public String getName()
- {
- return Name;
- }
- @Override
- public String getUnitType()
- {
- return UnitType;
- }
- @Override
- public String getArmorType()
- {
- return ArmorType;
- }
- }
- //Mutalisk
- package Units;
- import Base_Package.IFlyingUnit;
- import Base_Package.IGroundUnit;
- public class Mutalisk implements IFlyingUnit
- {
- String Name = "Mutalisk";
- String UnitType = "Bio";
- String ArmorType = "Light";
- int DMG = 5;
- int DMGBonus = 0;
- @Override
- public String getName()
- {
- return Name;
- }
- @Override
- public String getUnitType()
- {
- return UnitType;
- }
- @Override
- public String getArmorType()
- {
- return ArmorType;
- }
- @Override
- public void SetDMGUpgrade(int NewDMGBonus)
- {
- DMGBonus = NewDMGBonus;
- }
- @Override
- public int GetDMGBonus()
- {
- return DMGBonus;
- }
- @Override
- public int GetDMG()
- {
- return DMG+DMGBonus;
- }
- }
- //Zergling
- package Units;
- import Base_Package.IGroundUnit;
- public class Zergling implements IGroundUnit
- {
- String Name = "Zregling";
- String UnitType = "Bio";
- String ArmorType = "Lekkie";
- @Override
- public String getName()
- {
- return Name;
- }
- @Override
- public String getUnitType()
- {
- return UnitType;
- }
- @Override
- public String getArmorType()
- {
- return ArmorType;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement