Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.49 KB | None | 0 0
  1. class Human{
  2. protected String name;
  3. protected int health;
  4. protected int armorLevel;
  5. protected int magicLevel;
  6. protected int experience;
  7. protected int level;
  8. Human(){
  9. name = "Andrew The Magic";
  10. health = 100;
  11. armorLevel = 1;
  12. magicLevel = 1;
  13. experience=0;
  14. level =1;
  15. }
  16.  
  17. Human(String name){
  18. this(); //calling main constructor
  19. this.name = name;
  20. }
  21.  
  22. void fight() {}
  23. void levelUp() {}
  24. void showAbility() { System.out.println("Name: "+name+" HP: "+health+" ARMOR: "+armorLevel+" MAGIC: "+magicLevel+" EXP: "+experience+" LVL: "+level); }
  25. void yell(){ System.out.println("IM A CHARACTER ;-("); }
  26. }
  27.  
  28. //--------------------------------------------------------------
  29. class Warrior extends Human{
  30.  
  31. Warrior(){
  32. super();
  33. }
  34.  
  35. Warrior(String name){
  36. super(name);
  37. }
  38.  
  39. void fight(){
  40. System.out.println("I attack with sword");
  41. experience +=10;
  42. if (experience >= 20 ){ levelUp(); }
  43. }
  44.  
  45. void levelUp(){
  46. System.out.println("LEVEL UP!");
  47. health +=100;
  48. armorLevel +=25;
  49. level++;
  50. }
  51.  
  52. void yell(){
  53. System.out.println("IM A GLORIOUS WARRIOR "+name);
  54. }
  55. }
  56. //--------------------------------------------------------------
  57.  
  58. public class World{
  59.  
  60.  
  61. static void greeting(Human p){
  62. p.yell();
  63. }
  64.  
  65. public static void main(String[] args){
  66. Warrior w = new Warrior("Noname the Warrior");
  67. w.showAbility();
  68. w.fight();
  69. w.showAbility();
  70. w.fight();
  71. w.showAbility();
  72.  
  73. greeting(w);
  74. }
  75. }
  76.  
  77. class Human {
  78.  
  79. protected String name;
  80. protected int health;
  81. protected int armorLevel;
  82. protected int magicLevel;
  83. protected int experience;
  84. protected int level;
  85.  
  86. Human() {
  87. name = "Andrew The Magic";
  88. health = 100;
  89. armorLevel = 1;
  90. magicLevel = 1;
  91. experience = 0;
  92. level = 1;
  93. }
  94.  
  95. Human(String name) {
  96. this(); // calling main constructor
  97. this.name = name;
  98. }
  99.  
  100. void fight() {
  101. }
  102.  
  103. void levelUp() {
  104. }
  105.  
  106. void showAbility() {
  107. System.out.println("Name: " + name + " HP: " + health + " ARMOR: "
  108. + armorLevel + " MAGIC: " + magicLevel + " EXP: " + experience
  109. + " LVL: " + level);
  110. }
  111.  
  112. void yell() {
  113. System.out.println("IM A CHARACTER ;-(");
  114. }
  115. }
  116.  
  117. // --------------------------------------------------------------
  118. class Warrior extends Human {
  119.  
  120. Warrior() {
  121. super();
  122. }
  123.  
  124. Warrior(String name) {
  125. super(name);
  126. }
  127.  
  128. void fight() {
  129. System.out.println("I attack with sword");
  130. experience += 10;
  131. if (experience >= 20) {
  132. levelUp();
  133. }
  134. }
  135.  
  136. void levelUp() {
  137. System.out.println("LEVEL UP!");
  138. health += 100;
  139. armorLevel += 25;
  140. level++;
  141. }
  142.  
  143. void yell() {
  144. System.out.println("IM A GLORIOUS WARRIOR " + name);
  145. }
  146. }
  147.  
  148. // --------------------------------------------------------------
  149.  
  150. public class World {
  151.  
  152. static void greeting(Human p) {
  153. p.yell();
  154. }
  155.  
  156. public static void main(String[] args) {
  157. Warrior w = new Warrior("Noname the Warrior");
  158. w.showAbility();
  159. w.fight();
  160. w.showAbility();
  161. w.fight();
  162. w.showAbility();
  163.  
  164. greeting(w);
  165. }
  166.  
  167. }
  168.  
  169. class Human {
  170.  
  171. protected String name;
  172. protected int health;
  173. protected int armorLevel;
  174. protected int magicLevel;
  175. protected int experience;
  176. protected int level;
  177.  
  178. Human() {
  179. name = "Andrew The Magic";
  180. health = 100;
  181. armorLevel = 1;
  182. magicLevel = 1;
  183. experience = 0;
  184. level = 1;
  185. }
  186.  
  187. Human(String name) {
  188. this(); // calling main constructor
  189. this.name = name;
  190. }
  191.  
  192. void showAbility() {
  193. System.out.println("Name: " + name + " HP: " + health + " ARMOR: "
  194. + armorLevel + " MAGIC: " + magicLevel + " EXP: " + experience
  195. + " LVL: " + level);
  196. }
  197.  
  198. void yell() {
  199. System.out.println("IM A CHARACTER ;-(");
  200. }
  201. }
  202.  
  203. protected int health;
  204. protected int armorLevel;
  205. protected int magicLevel;
  206. protected int experience;
  207. protected int level;
  208.  
  209. class Human {
  210.  
  211. protected String name;
  212.  
  213. Human() {
  214. name = "Andrew The Magic";
  215. }
  216.  
  217. Human(String name) {
  218. this(); // calling main constructor
  219. this.name = name;
  220. }
  221.  
  222. void showAbility() {
  223. System.out.println("Name: " + name);
  224. }
  225.  
  226. void yell() {
  227. System.out.println("IM A CHARACTER ;-(");
  228. }
  229. }
  230.  
  231. // --------------------------------------------------------------
  232. class Warrior extends Human {
  233.  
  234. protected int health;
  235. protected int armorLevel;
  236. protected int magicLevel;
  237. protected int experience;
  238. protected int level;
  239.  
  240. Warrior() {
  241. super();
  242. health = 100;
  243. armorLevel = 1;
  244. magicLevel = 1;
  245. experience = 0;
  246. level = 1;
  247. }
  248.  
  249. Warrior(String name) {
  250. super(name);
  251. health = 100;
  252. armorLevel = 1;
  253. magicLevel = 1;
  254. experience = 0;
  255. level = 1;
  256. }
  257.  
  258. void fight() {
  259. System.out.println("I attack with sword");
  260. experience += 10;
  261. if (experience >= 20) {
  262. levelUp();
  263. }
  264. }
  265.  
  266. void levelUp() {
  267. System.out.println("LEVEL UP!");
  268. health += 100;
  269. armorLevel += 25;
  270. level++;
  271. }
  272.  
  273. void yell() {
  274. System.out.println("IM A GLORIOUS WARRIOR " + name);
  275. }
  276. }
  277.  
  278. Warrior() {
  279. this("Andrew The Magic");
  280. }
  281.  
  282. Warrior(String name) {
  283. super(name);
  284. health = 100;
  285. armorLevel = 1;
  286. magicLevel = 1;
  287. experience = 0;
  288. level = 1;
  289. }
  290.  
  291. Human() {
  292. name = "Andrew The Magic";
  293. }
  294.  
  295. Human(String name) {
  296. this.name = name;
  297. }
  298.  
  299. static void greeting(Human p) { // Takes a Human as a parameter,
  300. // so a Warrior will be casted to a Human
  301. p.yell(); // call yell() in the class Human
  302. }
  303.  
  304. class Human {
  305.  
  306. protected String name;
  307.  
  308. Human() {
  309. name = "Andrew The Magic";
  310. }
  311.  
  312. Human(String name) {
  313. this.name = name;
  314. }
  315.  
  316. void showAbility() {
  317. System.out.println("Name: " + name);
  318. }
  319.  
  320. void yell() {
  321. System.out.println("I'M A CHARACTER ;-(");
  322. }
  323. }
  324.  
  325. // --------------------------------------------------------------
  326. class Warrior extends Human {
  327.  
  328. protected int health;
  329. protected int armorLevel;
  330. protected int magicLevel;
  331. protected int experience;
  332. protected int level;
  333.  
  334. Warrior() {
  335. this("Andrew The Magic");
  336. }
  337.  
  338. Warrior(String name) {
  339. super(name);
  340. health = 100;
  341. armorLevel = 1;
  342. magicLevel = 1;
  343. experience = 0;
  344. level = 1;
  345. }
  346.  
  347. void fight() {
  348. System.out.println("I attack with sword");
  349. experience += 10;
  350. if (experience >= 20) {
  351. levelUp();
  352. }
  353. }
  354.  
  355. void levelUp() {
  356. System.out.println("LEVEL UP!");
  357. health += 100;
  358. armorLevel += 25;
  359. level++;
  360. }
  361.  
  362. void yell() {
  363. System.out.println("IM A GLORIOUS WARRIOR " + name);
  364. }
  365. }
  366.  
  367. // --------------------------------------------------------------
  368.  
  369. public class World {
  370.  
  371. public static void main(String[] args) {
  372. Warrior w = new Warrior("Noname the Warrior");
  373. w.showAbility();
  374. w.fight();
  375. w.showAbility();
  376. w.fight();
  377. w.showAbility();
  378.  
  379. w.yell();
  380. }
  381.  
  382. }
  383.  
  384. class Human {
  385. protected String name;
  386. protected int health = 100;
  387. protected int armorLevel = 1;
  388. protected int magicLevel = 1;
  389. protected int experience = 0;
  390. protected int level = 1;
  391.  
  392. Human() {
  393. this("Andrew The Magic");
  394. }
  395.  
  396. Human(String name) {
  397. this.name = name;
  398. }
  399.  
  400. void fight() {} // Dubious, as mentioned above
  401. void levelUp() {} // Dubious, as mentioned above
  402.  
  403. void showAbility() {
  404. System.out.printf("Name: %s HP: %d ARMOR: %d MAGIC: %d EXP: %d LVL: %dn",
  405. name, health, armorLevel, magicLevel, experience, level);
  406. }
  407.  
  408. void yell() {
  409. System.out.println("IM A CHARACTER ;-(");
  410. }
  411. }
  412.  
  413. public String toString(){
  414. return "Name: " + this.name; // Going by Manny Meng's feedback
  415. }
  416. void showAbility(){
  417. System.out.println(this);
  418. }
  419.  
  420. //Warrior class.
  421. public String toString(){
  422. return super.toString() + "HP: " + this.health; //Add the rest.
  423. }
  424.  
  425. // --------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement