Advertisement
Zepdo

monster class

Oct 14th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3.  
  4. public class monster {
  5. int strength;
  6. String name;
  7. String[] names = {"Slime","Ghost","Goblin","Spider","Wraith","Skeleton", "Dragon", "Hydra"};
  8.  
  9. //constructor
  10. Random rand = new Random();
  11. monster(){
  12. int x = rand.nextInt(7);
  13.  
  14. if(x < 5) {
  15. this.name = names[7];
  16. this.strength = 30 + rand.nextInt(10);
  17. }else if(x<10) {
  18. this.name = names[6];
  19. this.strength = 20 + rand.nextInt(20);
  20. }else if(x<20) {
  21. this.name = names[5];
  22. this.strength = 15 + rand.nextInt(10);
  23. }else if(x<30) {
  24. this.name = names[4];
  25. this.strength = 15 + rand.nextInt(15);
  26. }else if(x<40) {
  27. this.name = names[3];
  28. this.strength = 5+ rand.nextInt(15);
  29. }else if(x<50) {
  30. this.name = names[2];
  31. this.strength = 5+ rand.nextInt(15);
  32. }else if(x<75) {
  33. this.name = names[1];
  34. this.strength = rand.nextInt(10);
  35. }else {
  36. this.name = names[0];
  37. this.strength = rand.nextInt(10);
  38. }
  39.  
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement