Advertisement
zero50x

like random JAVA

Mar 3rd, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.47 KB | None | 0 0
  1. package xenophobia;
  2.  
  3. import java.util.Random;
  4.  
  5. public class RandomEvent {
  6.  
  7.     Random rndm = new Random();
  8.     private int max;
  9.     private int min;
  10.  
  11.     public RandomEvent(){
  12.         max = 10;
  13.         min = 0;
  14.     }
  15.  
  16.     public void eventChance(double currentThreat){
  17.         int odds = rndm.nextInt((max - min) + 1) + min;
  18.         if (odds == 7 || odds == 6){
  19.             if (currentThreat <= 49){
  20.                 System.out.println(printEvent());
  21.             }
  22.             else {
  23.                 System.out.println(threatEvent());
  24.             }
  25.         }  
  26.     }
  27.  
  28.     public String printEvent(){
  29.         int eventNum = rndm.nextInt((max - min) + 1) + min;
  30.  
  31.         switch(eventNum){
  32.         case 0:
  33.             return "You miss your parents.";
  34.         case 1:
  35.             return "You hear something break in the distance.";
  36.         case 2:
  37.             return "It's dead silent.";
  38.         case 3:
  39.             return "You feel lightheaded.";
  40.         case 4:
  41.             return "You can't hear the stranger's footsteps any more.";
  42.         case 5:
  43.             return "Something topples over a few aisles away.";
  44.         case 6:
  45.             return "You're tired.";
  46.         case 7:
  47.             return "Your hands feel numb.";
  48.         case 8:
  49.             return "You feel cold.";
  50.         default:
  51.             return "Footsteps echo across the store.";
  52.         }
  53.     }
  54.  
  55.     public String threatEvent(){
  56.         int eventNum = rndm.nextInt((max - min) + 1) + min;
  57.  
  58.         switch(eventNum){
  59.         case 0:
  60.             return "It's difficult to breathe.";
  61.         case 1:
  62.             return "You can clearly hear the stranger's footsteps.";
  63.         case 2:
  64.             return "It's close.";
  65.         case 3:
  66.             return "It's coming for you.";
  67.         case 4:
  68.             return "You can hear glass breaking not too far away.";
  69.         case 5:
  70.             return "You don't feel safe here.";
  71.         case 6:
  72.             return "You feel sick.";
  73.         case 7:
  74.             return "Something heavy falls down closeby.";
  75.         case 8:
  76.             return "Your vision is getting blurry.";
  77.         case 9:
  78.             return "Everything feels hazy.";
  79.         default:
  80.             return "It's getting closer.";         
  81.         }
  82.     }
  83.  
  84.     public String describeFood(){
  85.         int descriptionNum = rndm.nextInt((max - min) + 1) + min;
  86.         switch(descriptionNum){
  87.         case 1:
  88.             return "...It tastes terrible.";
  89.         case 2:
  90.             return "It's surprisingly tasty.";
  91.         case 3:
  92.             return "You feel slightly guilty for eating it.";
  93.         case 4:
  94.             return "It tastes slightly odd.";
  95.         case 5:
  96.             return "It's delicious.";
  97.         case 6:
  98.             return "You feel slightly better.";
  99.         case 7:
  100.             return "It tastes amazing.";
  101.         case 8:
  102.             return "It has a mild, pleasant flavour.";
  103.         case 9:
  104.             return "But shouldn't you be focusing on something else?";
  105.         case 10:
  106.             return "You feel full.";
  107.         default:
  108.             return "It's alright.";
  109.         }
  110.     }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement