package learning; import static learning.VocationEnum.*; public class Character { int lvl = 10, hp, mp, cap; Double exp; VocationEnum vocation; public void print() { System.out.println(" Postać na poziomie " + lvl + " posiada " + exp.intValue() + " doświadczenia. "); printProfessionResults(); } private void printProfessionResults() { switch(vocation) { case KNIGHT : System.out.println("Knight posiada: "); break; case PALADIN: System.out.println("Paladin posiada: "); break; case SORCERER: System.out.println("Sorcerer posiada: "); break; case DRUID: System.out.println(" Elder Druid posiada: "); break; } System.out.println(hp + " życia"); System.out.println(mp + " many. "); System.out.println(cap + " capa. "); System.out.println(); } void askForProfession() { System.out.println(" Wybierz numer swojej profesji lub q by zakończyć: "); System.out.println(" 1. EK "); System.out.println(" 2. RP "); System.out.println(" 3. MS "); System.out.println(" 4. ED "); } boolean isVal(int ch) { if(ch < '1' | ch > 4 & ch != 'q') { return false; } else { return true; } } public void setProfession(char choice) { switch(choice) { case '1': vocation = KNIGHT; break; case '2': vocation = PALADIN; break; case '3': vocation = SORCERER; break; case '4': vocation = DRUID; break; } } public void calculate() { exp = 50.0 / 3.0 * ((lvl * lvl * lvl) - (6 * (lvl * lvl)) + (17 * lvl) - 12); if(vocation == KNIGHT) { calculateKnight(); } else if (vocation == PALADIN) { calculatePaladin(); } else { calculateMaginProfession(); } } private void calculateKnight() { hp = 5*(3 * lvl +13); mp = 5*(lvl + 10); cap = 5*(5 * lvl + 54); } private void calculatePaladin() { hp = 5*(2 * lvl + 21); mp = 5*(3 * lvl - 6); cap = 10*(2 * lvl + 31); } private void calculateMaginProfession() { hp = 5*(lvl + 29); mp = 5*(6 * lvl - 30); cap = 10*(lvl + 39); } }