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...
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...
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...
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"...
Programming Language: C# CheckingAccount class You will implement the CheckingAccount Class in Visual Studio. This is...
Programming Language: C# CheckingAccount class You will implement the CheckingAccount Class in Visual Studio. This is a sub class is derived from the Account class and implements the ITransaction interface. There are two class variables i.e. variables that are shared but all the objects of this class. A short description of the class members is given below: CheckingAccount Class Fields $- COST_PER_TRANSACTION = 0.05 : double $- INTEREST_RATE = 0.005 : double - hasOverdraft: bool Methods + «Constructor» CheckingAccount(balance =...
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 computer assignment, you are to write a C++ program to implement a class for...
For this computer assignment, you are to write a C++ program to implement a class for binary trees. To deal with variety of data types, implement this class as a template. Most of the public member functions of the BinaryTree class call private member functions of the class (with the same name). These private member functions can be implemented as either recursive or non-recursive, but clearly, recursive versions of these functions are preferable because of their short and simple implementations...
For this computer assignment, you are to write a C++ program to implement a class for...
For this computer assignment, you are to write a C++ program to implement a class for binary trees. To deal with variety of data types, implement this class as a template. Most of the public member functions of the BinaryTree class call private member functions of the class (with the same name). These private member functions can be implemented as either recursive or non-recursive, but clearly, recursive versions of these functions are preferable because of their short and simple implementations...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT