Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need this in Java please. thank you. Background: When you design a piece of software, you often don't consider that the users may not speak
Need this in Java please. thank you.
Background: When you design a piece of software, you often don't consider that the users may not speak the same language you do. Companies who wish to ship their software to different countries will need to "internationalize" their applications. Typically this is done by translating all strings used in the interface to the various languages. In this lab, you'll be writing a number guessing game. The game will pick a random number between 0 and 100. You'll prompt the user to enter their guess and you'll let them know if they guessed too high, too low, or if they guessed correctly. You'll allow them to keep guessing until they reach the correct answer. The game can be played in English, Spanish, French or Simplified Chinese To avoid writing four different versions of this software, you will leverage OOP and Polymorphism to provide the strings from each language. You'll start with a language class. It will have abstract methods for every possible string you may use in your interface. Then you'll create English, Spanish, French and Simplified Chinese classes which will override the abstract class' methods and return the appropriate string. Classes you must create: Define an abstract Language class It should have 4 abstract methods all of which should return a string: o make_guess() o too_low() o too_high() o correct() Define a class called English which inherits from Language. Define a class called Spanish which inherits from Language. Define a class called French which inherits from Language. Define a class called Simplified Chinese which inherits from Language. Each class will need to override all 4 inherited methods and each should return a string as per the table on the next page. Hint: You'll probably want to copy and paste the strings from each language: Language make_guess() correct() English Guess a number too_low() too_high() Too Low Too High Demasiado bajo Demasiado alto Correct Spanish Adivina un numero Correcto Correct French Devinez un nombre Trop bas Simplified *18 Chinese All translations above are from google translate Trop haut * TE Define a class called GuessNumber. o It must have a method called play game() This method will first pick a random number between 0 and 100. In java: o Add "import java.util . Random" at the top of this class o Random myRand = new Random(); o myRand.nextInt(100); In C#: o Random myRand = new Random(); o myRand.Next(100); Prompt the user to select a language to play in: Choose your language 1. English 2. Espaol 3. Franais 4. ** If the user selects English, using polymorphism, create a variable of type Language and instantiate an English object on it. If the user selects French, do the same with a variable of type Language with a new French object on it, etc... . Using the object you created in the last step, prompt the user to enter their guess. If your object was called myLang, you should be able to just type: print(myLang.make_guess()); This will call the make_guess() method in the appropriate language that returns a string, which you can then print. Read in the user's guess. If it's too high, too low or correct, give them the appropriate prompt in the appropriate language. Driver Program: . In your main method, simply make an instance of GuessNumber and call play game() on it. Sample Output: Choose your language 1. English 2. Espaol 3. Franais 4. 15*** 1 Guess a number 50 Too High Guess a number 25 Too Low Guess a number 33 Too Low Guess a number 40 Too Low 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