Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Main
- package DecoChar;
- import java.util.Scanner;
- import DecoChar.Character.ListEq;
- public class Main {
- public static void main(String[] args) {
- Scanner Input = new Scanner(System.in);
- Character CharOb = null;
- int MenuOption;
- CharOb = new MainCharacter();
- do {
- menu();
- MenuOption = Input.nextInt();
- switch (MenuOption) {
- case 1:
- CharOb = new MainCharacter();
- CharOb.CheckStats();
- break;
- case 2:
- if (CharOb.CurrentEq[0] == null) {
- CharOb = new Gloves(CharOb);
- CharOb.CurrentEq[0] = new Gloves(CharOb);
- System.out.println("Założono rękawice");
- } else {
- CharOb.CurrentEq[0] = null;
- CharOb.Deco = ListEq.GLOVES;
- CharOb.RemovDeco(CharOb);
- System.out.println("Zdjęto rękawice");
- }
- CharOb.CheckStats();
- break;
- case 3:
- if (CharOb.CurrentEq[1] == null) {
- CharOb = new Shoes(CharOb);
- CharOb.CurrentEq[1] = new Shoes(CharOb);
- System.out.println("Założono buty");
- } else {
- CharOb.CurrentEq[1] = null;
- CharOb.Deco = ListEq.SHOES;
- CharOb.RemovDeco(CharOb);
- System.out.println("Zdjęto buty");
- }
- CharOb.CheckStats();
- break;
- case 4:
- if (CharOb.CurrentEq[2] == null) {
- CharOb = new Pants(CharOb);
- CharOb.CurrentEq[2] = new Pants(CharOb);
- System.out.println("Założono spodnie");
- } else {
- CharOb.CurrentEq[2] = null;
- CharOb.Deco = ListEq.PANTS;
- CharOb.RemovDeco(CharOb);
- System.out.println("Zdjęto spodnie");
- }
- CharOb.CheckStats();
- break;
- case 5:
- if (CharOb.CurrentEq[3] == null) {
- CharOb = new Helmet(CharOb);
- CharOb.CurrentEq[3] = new Helmet(CharOb);
- System.out.println("Założono hełm");
- } else {
- CharOb.CurrentEq[3] = null;
- CharOb.Deco = ListEq.HELMET;
- CharOb.RemovDeco(CharOb);
- System.out.println("Zdjęto hełm");
- }
- CharOb.CheckStats();
- break;
- case 6:
- if (CharOb.CurrentEq[5] == null) {
- CharOb = new Sword(CharOb);
- CharOb.CurrentEq[5] = new Sword(CharOb);
- System.out.println("Założono miecz");
- } else {
- CharOb.CurrentEq[5] = null;
- CharOb.Deco = ListEq.SWORD;
- CharOb.RemovDeco(CharOb);
- System.out.println("Zdjęto miecz");
- }
- CharOb.CheckStats();
- break;
- case 7:
- if (CharOb.CurrentEq[6] == null) {
- CharOb = new Chest(CharOb);
- CharOb.CurrentEq[6] = new Chest(CharOb);
- System.out.println("Założono zbroje");
- } else {
- CharOb.CurrentEq[6] = null;
- CharOb.Deco = ListEq.CHEST;
- CharOb.RemovDeco(CharOb);
- System.out.println("Zdjęto zbroje");
- }
- CharOb.CheckStats();
- break;
- case 0:
- break;
- default:
- System.out.println("Wprowadz liczbe od 0-7.");
- }
- } while (MenuOption != 0);
- Input.close();
- }
- public static void menu() {
- System.out.println("1.Aby zresetować postać.");
- System.out.println("2.Aby założyć lub zdjąć rękawice.");
- System.out.println("3.Aby założyć lub zdjąć buty.");
- System.out.println("4.Aby założyć lub zdjąć spodnie.");
- System.out.println("5.Aby założyć lub zdjąć hełm.");
- System.out.println("6.Aby założyć lub zdjąć miecz.");
- System.out.println("7.Aby założyć lub zdjąć zbroje.");
- System.out.println("Wcisnij 0 aby zakończyć program.\n");
- }
- }
- //Character
- package DecoChar;
- public abstract class Character {
- String Name;
- int HP = 0;
- int Atk = 0;
- int Def = 0;
- ListEq Deco = ListEq.NONE;
- Character[] CurrentEq = new Character[7];
- enum ListEq {
- NONE,
- GLOVES,
- SHOES,
- PANTS,
- HELMET,
- SWORD,
- CHEST
- }
- public void CheckStats() {
- System.out.println("\n"+Name + ":");
- System.out.println("Statystki postaci : ");
- System.out.println("Hp: " + HP);
- System.out.println("Atk: " + Atk);
- System.out.println("Def: " + Def);
- System.out.println();
- }
- public void RemovDeco(Character MainChar) {
- switch (Deco) {
- case GLOVES:
- MainChar.AddHP(-Gloves.HP);
- MainChar.AddAtk(-Gloves.Atk);
- MainChar.AddDef(-Gloves.Def);
- break;
- case SHOES:
- MainChar.AddHP(-Shoes.HP);
- MainChar.AddAtk(-Shoes.Atk);
- MainChar.AddDef(-Shoes.Def);
- break;
- case PANTS:
- MainChar.AddHP(-Pants.HP);
- MainChar.AddAtk(-Pants.Atk);
- MainChar.AddDef(-Pants.Def);
- break;
- case HELMET:
- MainChar.AddHP(-Helmet.HP);
- MainChar.AddAtk(-Helmet.Atk);
- MainChar.AddDef(-Helmet.Def);
- break;
- case SWORD:
- MainChar.AddHP(-Sword.HP);
- MainChar.AddAtk(-Sword.Atk);
- MainChar.AddDef(-Sword.Def);
- break;
- case CHEST:
- MainChar.AddHP(-Chest.HP);
- MainChar.AddAtk(-Chest.Atk);
- MainChar.AddDef(-Chest.Def);
- break;
- default:
- break;
- }
- }
- public void setNazwa(String Name) {
- this.Name = Name;
- }
- public String getName() {
- return this.Name;
- }
- public void setHP(int HP) {
- this.HP = HP;
- }
- public void AddHP(int HP) {
- this.HP += HP;
- }
- public int getHP() {
- return this.HP;
- }
- public void setAtk(int ATK) {
- this.Atk = ATK;
- }
- public void AddAtk(int ATK) {
- this.Atk += ATK;
- }
- public int getAtk() {
- return this.Atk;
- }
- public void setDef(int Def) {
- this.Def = Def;
- }
- public void AddDef(int Def) {
- this.Def += Def;
- }
- public int getDef() {
- return this.Def;
- }
- public void setEq(Character[] EqList) {
- CurrentEq = EqList;
- }
- }
- //MainCharacter
- package DecoChar;
- public class MainCharacter extends Character {
- public MainCharacter() {
- setNazwa("Raziel");
- setHP(100);
- setAtk(15);
- setDef(5);
- }
- }
- //Pants
- package DecoChar;
- public class Pants extends MainCharacter
- {
- public static int HP = 8;
- public static int Atk = 4;
- public static int Def = 4;
- public Pants(Character CharOb)
- {
- setHP(CharOb.getHP() + HP);
- setAtk(CharOb.getAtk() + Atk);
- setDef(CharOb.getDef() + Def);
- setEq(CharOb.CurrentEq);
- }
- }
- //Shoes
- package DecoChar;
- public class Shoes extends MainCharacter
- {
- public static int HP = 10;
- public static int Atk = 1;
- public static int Def = 2;
- public Shoes(Character CharOb)
- {
- setHP(CharOb.getHP() + HP);
- setAtk(CharOb.getAtk() + Atk);
- setDef(CharOb.getDef() + Def);
- setEq(CharOb.CurrentEq);
- }
- }
- //Sword
- package DecoChar;
- public class Sword extends MainCharacter
- {
- public static int HP = 0;
- public static int Atk = 20;
- public static int Def = 10;
- public Sword(Character CharOb)
- {
- setHP(CharOb.getHP() + HP);
- setAtk(CharOb.getAtk() + Atk);
- setDef(CharOb.getDef() + Def);
- setEq(CharOb.CurrentEq);
- }
- }
- //Helmet
- package DecoChar;
- public class Helmet extends MainCharacter
- {
- public static int HP = 20;
- public static int Atk = 2;
- public static int Def = 10;
- public Helmet(Character CharOb)
- {
- setHP(CharOb.getHP() + HP);
- setAtk(CharOb.getAtk() + Atk);
- setDef(CharOb.getDef() + Def);
- setEq(CharOb.CurrentEq);
- }
- }
- //Gloves
- package DecoChar;
- public class Gloves extends MainCharacter
- {
- public static int HP = 3;
- public static int Atk = 9;
- public static int Def = 9;
- public Gloves(Character CharOb)
- {
- setHP(CharOb.getHP() + HP);
- setAtk(CharOb.getAtk() + Atk);
- setDef(CharOb.getDef() + Def);
- setEq(CharOb.CurrentEq);
- }
- }
- //Chest
- package DecoChar;
- public class Chest extends MainCharacter
- {
- public static int HP = 30;
- public static int Atk = 0;
- public static int Def = 20;
- public Chest(Character CharOb)
- {
- setHP(CharOb.getHP() + HP);
- setAtk(CharOb.getAtk() + Atk);
- setDef(CharOb.getDef() + Def);
- setEq(CharOb.CurrentEq);
- }
- }
Add Comment
Please, Sign In to add comment