Advertisement
DigiDuncan

MLServer

Jun 29th, 2015
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.30 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MLServer
  4. {
  5.     public void chooseStory (int choice)
  6.     {
  7.         switch (choice)
  8.         {
  9.         case 1:
  10.             story1();
  11.             break;
  12.         /*case 2:
  13.             story2();
  14.             break;
  15.         case 3:
  16.             story3();
  17.             break;
  18.         case 4:
  19.             story4();
  20.             break;*/
  21.         }
  22.     }
  23.    
  24.     public boolean startsWithAVowel (String word)
  25.     {
  26.         String lowerword = word.toLowerCase();
  27.        
  28.         if (lowerword.startsWith("a") || lowerword.startsWith("e") || lowerword.startsWith("i")
  29.                 || lowerword.startsWith("o") || lowerword.startsWith("u"))
  30.         {
  31.             return true;
  32.         }
  33.         else
  34.             return false;
  35.     }
  36.    
  37.     public void story1 ()
  38.     {
  39.         Scanner input = new Scanner(System.in);
  40.        
  41.         System.out.println("Time to fill in the blanks!");
  42.        
  43.         String name;
  44.             System.out.print("Name: ");
  45.             name = input.nextLine();
  46.         String gender;
  47.             String heshe;
  48.             String hisher;
  49.             String hesheupper;
  50.             System.out.print("Is " + name + "a m or an f?");
  51.             gender = input.nextLine();
  52.             if (gender.equals("f"))
  53.             {
  54.                 heshe = "she";
  55.                 hisher = "her";
  56.                 hesheupper = "She";
  57.             }
  58.             else
  59.             {
  60.                 heshe = "he";
  61.                 hisher = "his";
  62.                 hesheupper = "He";
  63.             }
  64.         String profession;
  65.             System.out.print("Profession: ");
  66.             profession = input.nextLine();
  67.         String place;
  68.             System.out.print("Place: ");
  69.             place = input.nextLine();
  70.         String place2;
  71.             System.out.print("Place: ");
  72.             place2 = input.nextLine();
  73.         String object;
  74.             System.out.print("Object: ");
  75.             object = input.nextLine();
  76.         String object2;
  77.             System.out.print("Object: ");
  78.             object2 = input.nextLine();
  79.         String object3;
  80.             System.out.print("Object: ");
  81.             object3 = input.nextLine();
  82.         String noun;
  83.             System.out.print("Noun: ");
  84.             noun = input.nextLine();
  85.         String animal;
  86.             System.out.print("Animal: ");
  87.             animal = input.nextLine();
  88.         String adjective;
  89.             System.out.print("Adjective: ");
  90.             adjective = input.nextLine();
  91.         String verbed;
  92.             System.out.print("Past-tense Verb: ");
  93.             verbed = input.nextLine();
  94.            
  95.         String profUpper = profession.substring(0, 1).toUpperCase() + profession.substring(1);
  96.         String placeUpper = place.substring(0, 1).toUpperCase() + place.substring(1);
  97.            
  98.         String aan1 = "a";
  99.         String aan2 = "a";
  100.         String aan3 = "a";
  101.         String aan4 = "a";
  102.         String aan5 = "a";
  103.        
  104.         if (startsWithAVowel(profession)) aan1 = "an";
  105.         if (startsWithAVowel(object)) aan5 = "an";
  106.         if (startsWithAVowel(animal)) aan2 = "an";
  107.         if (startsWithAVowel(noun)) aan3 = "an";
  108.         if (startsWithAVowel(object2)) aan4 = "an";
  109.        
  110.         System.out.println("\n" + name + " the " + profUpper + " Sails To " + placeUpper);
  111.         System.out.println("----------------------------");
  112.         System.out.println("One day, " + aan1 + " " + profession + " named " + name + " was sailing to " + place + ".\n"
  113.                 + "Then when " + heshe + " least expected it...\n"
  114.                 + "There was " + aan5 + " " + object + "! Then " + name + " threw " + aan2 + " " + animal +" at it."
  115.                 + " The " + object + " went back to its " + place2 + " home.\n"
  116.                 + "Then " + heshe +  " saw " + aan3 + " " + noun + ". \"I need " + aan4 + " " + object2 + "\" " + name + " said. " + hesheupper + " got " + hisher + " " + adjective + " " + object2 + ".\n"
  117.                 + hesheupper + " also got " + hisher + " " + object3 + ".\n"
  118.                 + hesheupper + " " + verbed + ", and " + heshe + " won. \nTHE END!.\n");
  119.     }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement