Advertisement
xi_arma

Untitled

Sep 5th, 2024
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.65 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class STORY {
  4.   private String mainCharacter;
  5.   private String dogName;
  6.   private String scarecrowName;
  7.   private String tinWoodmanName;
  8.   private String lionName;
  9.   private String witchOfTheNorthName;
  10.   private String wickedWitchOfTheEastName;
  11.   private String wickedWitchOfTheWestName;
  12.   private String wizardOfOzName;
  13.   private String munchkinsLeaderName;
  14.  
  15.   // Constructor to initialize all the character names
  16.   public STORY(String mainCharacter, String dogName, String scarecrowName, String tinWoodmanName,
  17.                String lionName, String witchOfTheNorthName, String wickedWitchOfTheEastName,
  18.                String wickedWitchOfTheWestName, String wizardOfOzName, String munchkinsLeaderName) {
  19.     this.mainCharacter = mainCharacter;
  20.     this.dogName = dogName;
  21.     this.scarecrowName = scarecrowName;
  22.     this.tinWoodmanName = tinWoodmanName;
  23.     this.lionName = lionName;
  24.     this.witchOfTheNorthName = witchOfTheNorthName;
  25.     this.wickedWitchOfTheEastName = wickedWitchOfTheEastName;
  26.     this.wickedWitchOfTheWestName = wickedWitchOfTheWestName;
  27.     this.wizardOfOzName = wizardOfOzName;
  28.     this.munchkinsLeaderName = munchkinsLeaderName;
  29.   }
  30.  
  31.   public void createStory() {
  32.     String story =  "\n\n\n" + mainCharacter + " and their little dog " + dogName + " lived in a small village in Kansas. " +
  33.  
  34.         mainCharacter + " adored " + dogName + " very much, and they would play with each other all the time.\n\n" +
  35.         "One day there was a horrible cyclone. \"We must reach the basement soon, " + dogName + "!\" cried " + mainCharacter + ". But it was too late.\n\n" +
  36.         "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" +
  37.         "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" +
  38.         "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" +
  39.         "\"Can you tell me a path to go back to Kansas?\" asked " + mainCharacter + ".\n\n" +
  40.         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" +
  41.         "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" +
  42.         "\"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" +
  43.         "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" +
  44.         "\"It sounds like you want to see the Wizard of Oz, too!\" cried " + mainCharacter + ". \"Come along with us!\"\n\n" +
  45.         "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" +
  46.         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" +
  47.         "\"I know,\" sniffed the Lion. \"I'd like to have some courage.\"\n\n" +
  48.         "\"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" +
  49.         "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" +
  50.         "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" +
  51.         "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" +
  52.         "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" +
  53.         "\"You saved us, Scarecrow,\" sighed " + mainCharacter + ". \"Thank you.\"\n\n" +
  54.         "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" +
  55.         "\"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" +
  56.         "\"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" +
  57.         "\"You are very evil!\" cried " + mainCharacter + ", and with that, they threw a bucket of water over the Witch, " + wickedWitchOfTheWestName + ".\n\n" +
  58.         "\"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" +
  59.         "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" +
  60.         "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" +
  61.         "\"How will I get back to Kansas?\" asked " + mainCharacter + ".\n\n" +
  62.         "The Wizard, " + wizardOfOzName + ", smiled. \"You've had the power all along. Your magic silver shoes will take you anywhere you command!\"\n\n" +
  63.         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.";
  64.  
  65.     // Print the story in a table format with a maximum line width of 145 characters
  66.     int lineWidth = 145;
  67.     String[] storyLines = story.split("\n");
  68.     for (String line : storyLines) {
  69.       // Wrap long lines
  70.       if (line.length() > lineWidth) {
  71.         String[] words = line.split(" ");
  72.         StringBuilder wrappedLine = new StringBuilder();
  73.         for (String word : words) {
  74.           if (wrappedLine.length() + word.length() > lineWidth) {
  75.             System.out.println(wrappedLine.toString());
  76.             wrappedLine = new StringBuilder(word);
  77.           } else {
  78.             wrappedLine.append(" ").append(word);
  79.           }
  80.         }
  81.         System.out.println(wrappedLine.toString());
  82.       } else {
  83.         System.out.println(line);
  84.       }
  85.     }
  86.   }
  87.  
  88.   public static void main(String[] args) {
  89.     Scanner scanner = new Scanner(System.in);
  90.  
  91.     // Input for character names
  92.     System.out.print("Enter the main character's name: ");
  93.     String mainCharacter = scanner.nextLine();
  94.     System.out.print("Enter the dog's name: ");
  95.     String dogName = scanner.nextLine();
  96.     System.out.print("Enter the Scarecrow's name: ");
  97.     String scarecrowName = scanner.nextLine();
  98.     System.out.print("Enter the Tin Woodman's name: ");
  99.     String tinWoodmanName = scanner.nextLine();
  100.     System.out.print("Enter the Lion's name: ");
  101.     String lionName = scanner.nextLine();
  102.     System.out.print("Enter the Witch of the North's name: ");
  103.     String witchOfTheNorthName = scanner.nextLine();
  104.     System.out.print("Enter the Wicked Witch of the East's name: ");
  105.     String wickedWitchOfTheEastName = scanner.nextLine();
  106.     System.out.print("Enter the Wicked Witch of the West's name: ");
  107.     String wickedWitchOfTheWestName = scanner.nextLine();
  108.     System.out.print("Enter the Wizard of Oz's name: ");
  109.     String wizardOfOzName = scanner.nextLine();
  110.     System.out.print("Enter the Munchkins leader's name: ");
  111.     String munchkinsLeaderName = scanner.nextLine();
  112.  
  113.     // Create the story object
  114.     STORY story = new STORY(mainCharacter, dogName, scarecrowName, tinWoodmanName, lionName, witchOfTheNorthName,
  115.                            wickedWitchOfTheEastName, wickedWitchOfTheWestName, wizardOfOzName, munchkinsLeaderName);
  116.  
  117.     // Print the story
  118.     story.createStory();
  119.     scanner.close();
  120.   }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement