Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the Speaker interface: public interface Speaker { public void speak(); public void announce(String str); } Then, create three classes that implement Speaker in various

image text in transcribed

Implement the Speaker interface: public interface Speaker { public void speak(); public void announce(String str); } Then, create three classes that implement Speaker in various ways: SpeakerOfThe House: speak method prints "I am Speaker of the House.", and the announce method takes the name of a bill in the form of a string and prints it in the sentence "The [bill] has passed!" SportsAnnouncer: speak method prints "Goal!", and the announce method takes the name of a team in the form of a string and prints the sentence "The team] have scored a goal!" Actor: speak method prints "I've been nominated for three Academy Awards.", and the announce method takes the name of a movie in the form of a string and prints the sentence, "I'm currently staring in [movie]." Create a driver class, and in the main method, prompt the user to enter three Strings -- the name of a bill, the name of a sports team, and the name of a movie. Then, create an object from each of the classes described above and call the speak and announce methods of each object, using the strings provided by the user

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Systems A 360-degree Approach

Authors: Jawwad ShamsiMuhammad Khojaye

1st Edition

0429531575, 9780429531576

More Books

Students also viewed these Databases questions

Question

What is topology? Explain with examples

Answered: 1 week ago

Question

What is DDL?

Answered: 1 week ago