Question

In: Computer Science

You'll notice that in the LearnAboutLanguages class there are a few todos. You need to implement...

You'll notice that in the LearnAboutLanguages class there are a few todos. You need to implement the three missing classes ( RussianSpeaker, JapaneseSpeaker and SwahiliSpeaker ). Then uncomment all the stuff marked "todo" and run the code!

Submit
1. Your three new .java files
2. A screenshot of your correct code running on your computer.

--

public class EnglishSpeaker implements LanguageSpeaker{

   @Override
   public String GetMyLanguage() {
       return "English";
   }

   @Override
   public String GetHi() {
       return "Hi";
   }

   @Override
   public String GetBye() {
       return "Bye";
   }
}
--

public interface LanguageSpeaker {
   String GetMyLanguage();
   String GetHi();
   String GetBye();
}
--

public class LearnAboutLanguages {
  
   public static void teachLanguage(LanguageSpeaker speaker) {
       System.out.println("Hello, I speak " + speaker.GetMyLanguage());
       System.out.println("To say \"hello\", we say: " + speaker.GetHi());
       System.out.println("To say \"bye\", we say: " + speaker.GetBye());
       System.out.println();
   }
  
   public static void main(String[] args) {
       LanguageSpeaker australian = new EnglishSpeaker();
       LanguageSpeaker uruguayan = new SpanishSpeaker();
       LanguageSpeaker mozambican = new PortugueseSpeaker();
      
       //TODO
       // LanguageSpeaker russian = new RussianSpeaker();
       // LanguageSpeaker japanese = new JapaneseSpeaker();
       // LanguageSpeaker kenyan = new SwahiliSpeaker();
      
       teachLanguage(australian);
       teachLanguage(uruguayan);
       teachLanguage(mozambican);
      
       //TODO
       //teachLanguage(russian);
       //teachLanguage(japanese);
       //teachLanguage(kenyan);
   }
}
--

public class PortugueseSpeaker implements LanguageSpeaker{

   @Override
   public String GetMyLanguage() {
       return "Português";
   }

   @Override
   public String GetHi() {
       return "olá";
   }

   @Override
   public String GetBye() {
       return "tchau";
   }
}
--

public class SpanishSpeaker implements LanguageSpeaker{

   @Override
   public String GetMyLanguage() {
       return "Español";
   }

   @Override
   public String GetHi() {
       return "Hola";
   }

   @Override
   public String GetBye() {
       return "Adios";
   }
}

Solutions

Expert Solution

I have implemented below three .java files::

1> RussianSpeaker.java :-

public class RussianSpeaker implements LanguageSpeaker{
    
    @Override
   public String GetMyLanguage() {
       return "русский";
   }

   @Override
   public String GetHi() {
       return "Здравствуй";
   }

   @Override
   public String GetBye() {
       return "до свидания";
   }
}

2> JapaneseSpeaker.java:-

public class JapaneseSpeaker implements LanguageSpeaker{
    
    @Override
   public String GetMyLanguage() {
       return "Японский";
   }

   @Override
   public String GetHi() {
       return "こんにちは";
   }

   @Override
   public String GetBye() {
       return "さようなら";
   }
}

3> SwahiliSpeaker.java

public class SwahiliSpeaker implements LanguageSpeaker{
    
    @Override
   public String GetMyLanguage() {
       return "Kiswahili";
   }

   @Override
   public String GetHi() {
       return "Hi";
   }

   @Override
   public String GetBye() {
       return "Kwaheri";
   }
}

Program :-

public class LearnAboutLanguages {
  
   public static void teachLanguage(LanguageSpeaker speaker) {
       System.out.println("Hello, I speak " + speaker.GetMyLanguage());
       System.out.println("To say \"hello\", we say: " + speaker.GetHi());
       System.out.println("To say \"bye\", we say: " + speaker.GetBye());
       System.out.println();
   }
  
   public static void main(String[] args) {
       LanguageSpeaker australian = new EnglishSpeaker();
       LanguageSpeaker uruguayan = new SpanishSpeaker();
       LanguageSpeaker mozambican = new PortugueseSpeaker();
      
       //TODO
       LanguageSpeaker russian = new RussianSpeaker();
       LanguageSpeaker japanese = new JapaneseSpeaker();
       LanguageSpeaker kenyan = new SwahiliSpeaker();
      
       teachLanguage(australian);
       teachLanguage(uruguayan);
       teachLanguage(mozambican);
      
       //TODO
       teachLanguage(russian);
       teachLanguage(japanese);
       teachLanguage(kenyan);
   }
}

Output:-

I hope you will understand the above program.

Do you feel needful and useful then please upvote me.

Thank you.


Related Solutions

For this writing task, you'll need to respond to the following scenario: Who are you? You...
For this writing task, you'll need to respond to the following scenario: Who are you? You work as department head in the information technology (IT) department at First Federal Bank. Part of your job is to conduct an ongoing assessment of risk for the institution and to recommend proper controls. Banking systems should be able to quickly collect and edit information, summarize results, and promptly correct any errors. You have identified a possible threat to "timeliness" of information. You have...
You'll implement a completely generic version of an algorithm to find the maximum of an array....
You'll implement a completely generic version of an algorithm to find the maximum of an array. Unlike in the past, when our algorithm only worked for int[] or double[], this version will work on any Java objects that are comparable, specifically any Java object that implements the Comparable interface. Create a public class named Max with a single class method named max. max should accept an array of Objects that implement Comparable and return the maximum. If the array is...
Similar to in HW1, you'll implement a left shift of decimals in a string, with combining...
Similar to in HW1, you'll implement a left shift of decimals in a string, with combining of multiple like digits into a single digit of double the value. The main difference between HW1 and this is that now the string representing a row in 2048 can be of any length! You'll implement a Combine class in a comparable .java file. As before, the input string can only include the characters '_', '2', and '4'. Unlike before, it can be of...
Here is another article for you to discuss. It's a little challenging, so you'll need to...
Here is another article for you to discuss. It's a little challenging, so you'll need to read it carefully. Post your reactions to this thread. What do you think the author is arguing here? Does he make good arguments? Why or why not? And do you agree with him? New York Times July 23, 2006 Conspiracy Theories 101 By STANLEY FISH Kevin Barrett, a lecturer at the University of Wisconsin at Madison, has now taken his place alongside Ward Churchill...
Behold, the power of interfaces! On this homework problem you'll implement a completely generic version of...
Behold, the power of interfaces! On this homework problem you'll implement a completely generic version of an algorithm to find the maximum of an array. Unlike in the past, when our algorithm only worked for int[] or double[], this version will work on any Java objects that are comparable, specifically any Java object that implements the Comparable interface. Create a public class named Max with a single class method named max. max should accept an array of Objects that implement...
for java, Behold, the power of interfaces! On this homework problem you'll implement a completely generic...
for java, Behold, the power of interfaces! On this homework problem you'll implement a completely generic version of an algorithm to find the maximum of an array. Unlike in the past, when our algorithm only worked for int[] or double[], this version will work on any Java objects that are comparable, specifically any Java object that implements the Comparable interface. Create a public class named Max with a single class method named max. max should accept an array of Objects...
I need to implement incrementalInserstionSort im stuck on that part import java.util.*; /** * This class...
I need to implement incrementalInserstionSort im stuck on that part import java.util.*; /** * This class represents chains of linked nodes that * can be sorted by a Shell sort. * * @author Charles Hoot * @author Frank M. Carrano * Modified by atb * @author YOUR NAME * @version 9/29/2020 */ public class ChainSort> { private Node firstNode; // reference to first node public ChainSort() { this.firstNode = null; } public void display() { Node currentNode = this.firstNode; while...
In this homework you will implement a Library class that uses your Book and Person class...
In this homework you will implement a Library class that uses your Book and Person class from homework 2, with slight modifications. The Library class will keep track of people with membership and the books that they have checked out. Book.java You will need to modify your Book.java from homework 2 in the following ways: field: dueDate (private)             A String containing the date book is due.  Dates are given in the format "DD MM YYYY", such as "01 02 2017"...
Description: In this program, you'll reuse the Monster data type you wrote in LA11A. Then, you'll...
Description: In this program, you'll reuse the Monster data type you wrote in LA11A. Then, you'll write a function that accepts a Monster as an argument by reference, then print the Monster to the screen. Again, this will be structured as a guided multiple choice quiz where you will choose the appropriate code for a program. After you have gotten a perfect score, write out the program and compile and run it to see it in action. Instructions: Choose the...
For this assignment you will implement a dynamic array. You are to build a class called...
For this assignment you will implement a dynamic array. You are to build a class called MyDynamicArray. Your dynamic array class should manage the storage of an array that can grow and shrink. The public methods of your class should be the following: MyDynamicArray(); Default Constructor. The array should be of size 2. MyDynamicArray(int s); For this constructor the array should be of size s. ~MyDynamicArray(); Destructor for the class. int& operator[](int i); Traditional [] operator. Should print a message...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT