Question
I seriously need help with this assignment. the following is the assignment followed by my code. I do not understand how to put it all
I seriously need help with this assignment. the following is the assignment followed by my code. I do not understand how to put it all together, need help please. Create a class that has a main() method. This class will be your virtual world application that will test the MyClone, ShoutBox, and class you decided to create in Module Seven. Document your code with comments.
MyClone.java
package virtualworld1; import java.util.*; import java.lang.*; import java.io.*; import java.util.Scanner;
public class MyClone { private String firstName; //Use of private specifier private String lastName;//Use of private specifier private String lastName; //CONSTRUCTOR THAT INITIALIZES THE PRIVATE VARIABLES public MyClone (String f,String l) { firstName=f; lastName=l; } //Method of encapsulation /** * @return the firstName */ public String getFirstName() { return firstName; } /** * @param firstName the firstName to set */ public void setFirstName(String firstName) { this.firstName = firstName; } /** * @return the lastName */ public String getLastName() { return lastName; } /** * @param lastName the lastName to set */ public void setLastName(String lastName) { this.lastName = lastName; } //INTRODUCE YOURSELF TO THE VIRTUAL WORLD public void introduction() { System.out.println("Hi, "+getFirstName()+" "+getLastName()+" Here. How are you. Hope Everyone is doing great."); } }
MyCloneTest.java (This class is having main method so we have to run this class.)
package virtualworld1;
public class MyCloneTest { /** * @param args */ public static void main(String[] args) { //CREATE OBJECT OF MyClone MyClone obj = new MyClone("Lawernce", "Standley"); //METHOD TO INTRODUCE YOURSELF obj.introduction(); } }
ShoutBox.java
package virtualworld1;
import java.util.Scanner;
public class ShoutBox { private Object scanner; public static void main(String[] args) { // main method shoutOutRandomMessage(); } public static void shoutOutRandomMessage() { String shoutSubject; String shoutObject; String shoutVerb; String shoutAdverbe; String shoutAdjective; int length; // instance variable that determines the length of the array Scanner input = new Scanner(System.in); // the Scanner utility is added System.out.println("You may choose how many words you want to enter. " + "Please write a number between 1 and 100 and hit Enter: "); length = input.nextInt(); // takes user input of integer int number = 0; // create array to store user words String[] subject = new String[length]; for(int counter = 0; counter < length; counter++){ System.out.println("Please enter Subject " + (counter+1) + ": "); subject[counter] = input.next(); // reads user input and stores the words in array } System.out.println("The Subjects of your choice are: "); for(int counter = 0; counter < length; counter++){ System.out.println(subject[counter]); } // create array to store user words String[] object = new String[length]; for(int counter = 0; counter < length; counter++){ System.out.println("Please enter Object " + (counter+1) + ": "); object[counter] = input.next(); // reads user input and stores the words in array } System.out.println("The Objects of your choice are: "); for(int counter = 0; counter < length; counter++){ System.out.println(object[counter]); } // create array to store user words String[] verb = new String[length]; for(int counter = 0; counter < length; counter++){ System.out.println("Please enter Verb " + (counter+1) + ": "); verb[counter] = input.next(); // reads user input and stores the words in array } System.out.println("The Verbs of your choice are: "); for(int counter = 0; counter < length; counter++){ System.out.println(verb[counter]); } // create array to store user words String[] adverb = new String[length]; for(int counter = 0; counter < length; counter++){ System.out.println("Please enter Adverb " + (counter+1) + ": "); adverb[counter] = input.next(); // reads user input and stores the words in array } System.out.println("The Adverbs of your choice are: "); for(int counter = 0; counter < length; counter++){ System.out.println(adverb[counter]); } // create array to store user words String[] adjective = new String[length]; for(int counter = 0; counter < length; counter++){ System.out.println("Please enter Adjective " + (counter+1) + ": "); adjective[counter] = input.next(); // reads user input and stores the words in array } System.out.println("The Adjectives of your choice are: "); for(int counter = 0; counter < length; counter++){ System.out.println(adjective[counter]); } // retrieve random number that equals index and returns array element int random = (int) (Math.random()*length); System.out.println("Your message is: " + subject[random] + " " + object[random] + " " + verb[random] + " " + adverb[random] + " " + adjective[random]); } }
package virtualworld1;
import java.util.Scanner;
public class ShoutOutScannedMessage {
public static void main(String[] args) { String stringArr[] = { "Hummingbirds cannot walk", "A lightning bolt is two miles long", "A goldfish has the memory span of two seconds", "An ostrich's eye is bigger than its brain", "peanuts is a ingredient in dynomite", "Non-dairy creamer is flammable", "Half of all bank robberies occur on Friday", "A month starting on Sunday has a Friday the 13th", "Ten inches of snow equals 1 inch of rain", "A rat can last longer without water than a camel"}; String selectedMessage = shoutOutCannedMessage(stringArr); System.out.println("You Selected :" + selectedMessage); } /** * method to return selected message * * @param stringArr * @return */ //Method to return selected message public static String shoutOutCannedMessage(String stringArr[]) { Scanner scanner = null; try { scanner = new Scanner(System.in); for (int i = 0; i < stringArr.length; i++) { System.out.println((i + 1) + ". " + stringArr[i]); } System.out.print("Select Message :"); int n = scanner.nextInt(); if (n > 0 && n <= 10) return stringArr[n - 1]; else return "Invalie Message Selection"; } catch (Exception e) { } return null;
} }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started