Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class STORY {
- private String mainCharacter;
- private String dogName;
- private String scarecrowName;
- private String tinWoodmanName;
- private String lionName;
- private String witchOfTheNorthName;
- private String wickedWitchOfTheEastName;
- private String wickedWitchOfTheWestName;
- private String wizardOfOzName;
- private String munchkinsLeaderName;
- // Constructor to initialize all the character names
- public STORY(String mainCharacter, String dogName, String scarecrowName, String tinWoodmanName,
- String lionName, String witchOfTheNorthName, String wickedWitchOfTheEastName,
- String wickedWitchOfTheWestName, String wizardOfOzName, String munchkinsLeaderName) {
- this.mainCharacter = mainCharacter;
- this.dogName = dogName;
- this.scarecrowName = scarecrowName;
- this.tinWoodmanName = tinWoodmanName;
- this.lionName = lionName;
- this.witchOfTheNorthName = witchOfTheNorthName;
- this.wickedWitchOfTheEastName = wickedWitchOfTheEastName;
- this.wickedWitchOfTheWestName = wickedWitchOfTheWestName;
- this.wizardOfOzName = wizardOfOzName;
- this.munchkinsLeaderName = munchkinsLeaderName;
- }
- public void createStory() {
- String story = "\n\n\n" + mainCharacter + " and their little dog " + dogName + " lived in a small village in Kansas. " +
- mainCharacter + " adored " + dogName + " very much, and they would play with each other all the time.\n\n" +
- "One day there was a horrible cyclone. \"We must reach the basement soon, " + dogName + "!\" cried " + mainCharacter + ". But it was too late.\n\n" +
- "After they were both uplifted by the tornado, the house landed at a mysterious place in Oz, and " + mainCharacter + " and " + dogName + " moved out of the house and looked around. They had landed on top of the evil witch of the East, " + wickedWitchOfTheEastName + ", killing her. Upon realizing, " + mainCharacter + " exclaimed, \"Oh my, " + dogName + "! The house fell on someone! I didn't mean to hurt anyone.\"\n\n" +
- "A happy group of tiny people came near " + mainCharacter + " and thanked them by explaining that they are the Munchkins. Their leader, " + munchkinsLeaderName + ", was especially grateful to " + mainCharacter + " because they had killed the wicked witch of the East, " + wickedWitchOfTheEastName + ", and freed the Munchkins from the witch's wicked spell forever.\n\n" +
- "Suddenly, another witch appeared; however, this was the good witch of the North, " + witchOfTheNorthName + ". She said: \"" + mainCharacter + ", you were very brave to free the Munchkins. If there is any help I can provide, just ask.\"\n\n" +
- "\"Can you tell me a path to go back to Kansas?\" asked " + mainCharacter + ".\n\n" +
- witchOfTheNorthName + " said: \"Sorry, I cannot! However, the Wizard of Oz, " + wizardOfOzName + ", can help you with that. But yes, you can take these magic silver shoes of the Wicked Witch of the East, " + wickedWitchOfTheEastName + ", because these may be of use later on. Now, follow the Yellow Brick Road all the way to the Emerald City; this path will lead you to the Wizard of Oz.\"\n\n" +
- "On the road, " + mainCharacter + " met a speaking scarecrow, " + scarecrowName + ", who said, \"My head is full of straw, and people believe that I'm a fool,\" and \"I'd provide the whole lot to have a mind.\"\n\n" +
- "\"I'll bet the Wizard of Oz ought to provide you with one,\" stated " + mainCharacter + ". \"I'm on a path to see him right this moment. Why don't you join us on our journey?\"\n\n" +
- "Further down the Yellow Brick Road, " + mainCharacter + ", " + dogName + ", and the speaking scarecrow, " + scarecrowName + ", observed a Tin Woodman, " + tinWoodmanName + ", who was rusted stiff. After " + mainCharacter + " oiled his corroded joints, the Tin Woodman was able to move freely. \"Ah, thank you, little one. I feel good as new—despite the fact that I nevertheless have no heart. When the tinman made me, he forgot to give me one.\"\n\n" +
- "\"It sounds like you want to see the Wizard of Oz, too!\" cried " + mainCharacter + ". \"Come along with us!\"\n\n" +
- "As they traveled through the forest, a massive Lion, " + lionName + ", jumped at " + dogName + " and roared. \"Don't you dare bite " + dogName + "!\" shouted " + mainCharacter + ".\n\n" +
- lionName + " blinked a tear and then hung his head in shame. " + mainCharacter + " was shocked. \"Why, you're almost nothing but a massive coward!\"\n\n" +
- "\"I know,\" sniffed the Lion. \"I'd like to have some courage.\"\n\n" +
- "\"The Wizard of Oz is going to give Scarecrow a brain and me a heart,\" stated the Tin Woodman, " + tinWoodmanName + ". \"Maybe he can assist you, too!\"\n\n" +
- "Thus, the Lion joined " + mainCharacter + ", " + dogName + ", Scarecrow, " + scarecrowName + ", and the Tin Woodman, " + tinWoodmanName + ". Soon the Yellow Brick Road helped them reach Emerald City. The tiny group nervously entered the large Throne Room and approached the Wizard of Oz, " + wizardOfOzName + ".\n\n" +
- "He listened to their requests and then answered, \"I have heard that you killed the Wicked Witch of the East, " + wickedWitchOfTheEastName + ". If you can free us from her sister, the Evil Witch of the West, " + wickedWitchOfTheWestName + ", then I will fulfill all your wishes. Now go!\"\n\n" +
- "But the depraved witch, " + wickedWitchOfTheWestName + ", was determined to kill " + mainCharacter + " and their friends. She sent several starving wolves to consume them. \"This is my fight!\" stated the Tin Woodman, " + tinWoodmanName + ". He swung his axe fiercely. The scared wolves turned and ran.\n\n" +
- "A screeching black cloud of untamed birds darkened the sky. \"Crows!\" yelled the Scarecrow, " + scarecrowName + ", \"This is my specialty!\" He waved his fingers excitedly. \"Boo! Go away! Shoo!\"\n\n" +
- "\"You saved us, Scarecrow,\" sighed " + mainCharacter + ". \"Thank you.\"\n\n" +
- "The Witch, " + wickedWitchOfTheWestName + ", was furious! She sent her winged monkeys to capture the little group. Chattering monkeys swooped down, grabbed the travelers, and flew back to the Evil Witch's castle.\n\n" +
- "\"So, you and your pals were going to ruin me, eh?\" said the Wicked Witch of the West, " + wickedWitchOfTheWestName + ", to " + mainCharacter + ". \"Well, I've turned the tables on all of you! The Tin Woodman, " + tinWoodmanName + ", is battered and twisted on a pile of razor-sharp rocks. The Scarecrow, " + scarecrowName + ", is absolutely unstuffed. I've captured your cowardly Lion, " + lionName + ", in a heavy cart.\"\n\n" +
- "\"And as for you, my dear. You and your annoying dog will spend the rest of your life working right here in my castle!\"\n\n" +
- "\"You are very evil!\" cried " + mainCharacter + ", and with that, they threw a bucket of water over the Witch, " + wickedWitchOfTheWestName + ".\n\n" +
- "\"Oh, no!\" cried the evil witch, " + wickedWitchOfTheWestName + ". \"Water will make me shrink and dissolve! Oh, I'm shrinking—melting, melting…\" Within moments the Evil Witch of the West turned into nothing more than a puddle on the floor.\n\n" +
- "The Witch's slaves were now free. To display their appreciation, they patched up the Tin Woodman, " + tinWoodmanName + ", stuffed the Scarecrow, " + scarecrowName + ", with new straw, and released the Lion, " + lionName + ". Shortly, " + mainCharacter + " and their pals were back on their journey to Emerald City.\n\n" +
- "The Wizard of Oz, " + wizardOfOzName + ", was pleased to see them. \"You have done what I expected. You will be rewarded.\" So, the Scarecrow, " + scarecrowName + ", obtained his brain, the Tin Woodman, " + tinWoodmanName + ", his heart, and the Lion, " + lionName + ", his courage.\n\n" +
- "\"How will I get back to Kansas?\" asked " + mainCharacter + ".\n\n" +
- "The Wizard, " + wizardOfOzName + ", smiled. \"You've had the power all along. Your magic silver shoes will take you anywhere you command!\"\n\n" +
- mainCharacter + " turned to their friends with lament. \"I will be going back home, but I shall miss you all very much.\" " + mainCharacter + " kissed them all farewell. Then, with the help of their magic shoes, " + mainCharacter + " and " + dogName + " traveled back to their home in Kansas.";
- // Print the story in a table format with a maximum line width of 145 characters
- int lineWidth = 145;
- String[] storyLines = story.split("\n");
- for (String line : storyLines) {
- // Wrap long lines
- if (line.length() > lineWidth) {
- String[] words = line.split(" ");
- StringBuilder wrappedLine = new StringBuilder();
- for (String word : words) {
- if (wrappedLine.length() + word.length() > lineWidth) {
- System.out.println(wrappedLine.toString());
- wrappedLine = new StringBuilder(word);
- } else {
- wrappedLine.append(" ").append(word);
- }
- }
- System.out.println(wrappedLine.toString());
- } else {
- System.out.println(line);
- }
- }
- }
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- // Input for character names
- System.out.print("Enter the main character's name: ");
- String mainCharacter = scanner.nextLine();
- System.out.print("Enter the dog's name: ");
- String dogName = scanner.nextLine();
- System.out.print("Enter the Scarecrow's name: ");
- String scarecrowName = scanner.nextLine();
- System.out.print("Enter the Tin Woodman's name: ");
- String tinWoodmanName = scanner.nextLine();
- System.out.print("Enter the Lion's name: ");
- String lionName = scanner.nextLine();
- System.out.print("Enter the Witch of the North's name: ");
- String witchOfTheNorthName = scanner.nextLine();
- System.out.print("Enter the Wicked Witch of the East's name: ");
- String wickedWitchOfTheEastName = scanner.nextLine();
- System.out.print("Enter the Wicked Witch of the West's name: ");
- String wickedWitchOfTheWestName = scanner.nextLine();
- System.out.print("Enter the Wizard of Oz's name: ");
- String wizardOfOzName = scanner.nextLine();
- System.out.print("Enter the Munchkins leader's name: ");
- String munchkinsLeaderName = scanner.nextLine();
- // Create the story object
- STORY story = new STORY(mainCharacter, dogName, scarecrowName, tinWoodmanName, lionName, witchOfTheNorthName,
- wickedWitchOfTheEastName, wickedWitchOfTheWestName, wizardOfOzName, munchkinsLeaderName);
- // Print the story
- story.createStory();
- scanner.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement