Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class MLServer
- {
- public void chooseStory (int choice)
- {
- switch (choice)
- {
- case 1:
- story1();
- break;
- /*case 2:
- story2();
- break;
- case 3:
- story3();
- break;
- case 4:
- story4();
- break;*/
- }
- }
- public boolean startsWithAVowel (String word)
- {
- String lowerword = word.toLowerCase();
- if (lowerword.startsWith("a") || lowerword.startsWith("e") || lowerword.startsWith("i")
- || lowerword.startsWith("o") || lowerword.startsWith("u"))
- {
- return true;
- }
- else
- return false;
- }
- public void story1 ()
- {
- Scanner input = new Scanner(System.in);
- System.out.println("Time to fill in the blanks!");
- String name;
- System.out.print("Name: ");
- name = input.nextLine();
- String gender;
- String heshe;
- String hisher;
- String hesheupper;
- System.out.print("Is " + name + "a m or an f?");
- gender = input.nextLine();
- if (gender.equals("f"))
- {
- heshe = "she";
- hisher = "her";
- hesheupper = "She";
- }
- else
- {
- heshe = "he";
- hisher = "his";
- hesheupper = "He";
- }
- String profession;
- System.out.print("Profession: ");
- profession = input.nextLine();
- String place;
- System.out.print("Place: ");
- place = input.nextLine();
- String place2;
- System.out.print("Place: ");
- place2 = input.nextLine();
- String object;
- System.out.print("Object: ");
- object = input.nextLine();
- String object2;
- System.out.print("Object: ");
- object2 = input.nextLine();
- String object3;
- System.out.print("Object: ");
- object3 = input.nextLine();
- String noun;
- System.out.print("Noun: ");
- noun = input.nextLine();
- String animal;
- System.out.print("Animal: ");
- animal = input.nextLine();
- String adjective;
- System.out.print("Adjective: ");
- adjective = input.nextLine();
- String verbed;
- System.out.print("Past-tense Verb: ");
- verbed = input.nextLine();
- String profUpper = profession.substring(0, 1).toUpperCase() + profession.substring(1);
- String placeUpper = place.substring(0, 1).toUpperCase() + place.substring(1);
- String aan1 = "a";
- String aan2 = "a";
- String aan3 = "a";
- String aan4 = "a";
- String aan5 = "a";
- if (startsWithAVowel(profession)) aan1 = "an";
- if (startsWithAVowel(object)) aan5 = "an";
- if (startsWithAVowel(animal)) aan2 = "an";
- if (startsWithAVowel(noun)) aan3 = "an";
- if (startsWithAVowel(object2)) aan4 = "an";
- System.out.println("\n" + name + " the " + profUpper + " Sails To " + placeUpper);
- System.out.println("----------------------------");
- System.out.println("One day, " + aan1 + " " + profession + " named " + name + " was sailing to " + place + ".\n"
- + "Then when " + heshe + " least expected it...\n"
- + "There was " + aan5 + " " + object + "! Then " + name + " threw " + aan2 + " " + animal +" at it."
- + " The " + object + " went back to its " + place2 + " home.\n"
- + "Then " + heshe + " saw " + aan3 + " " + noun + ". \"I need " + aan4 + " " + object2 + "\" " + name + " said. " + hesheupper + " got " + hisher + " " + adjective + " " + object2 + ".\n"
- + hesheupper + " also got " + hisher + " " + object3 + ".\n"
- + hesheupper + " " + verbed + ", and " + heshe + " won. \nTHE END!.\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement