Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help please Telp/FAQ 11.12 LAB^: Speaker (interfaces) Create an interface Speaker which has the following methods: speak() which takes no parameters and returns void

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

please help please

Telp/FAQ 11.12 LAB^: Speaker (interfaces) Create an interface Speaker which has the following methods: speak() which takes no parameters and returns void speak() which takes a single String parameter and returns void Given unrelated classes Philosopher and TalkShowHost, modify the classes to implement the Speaker interface. A Driver method has been given. Ex. If the input is: Descartes I think, therefore I am I suppose therefore that all things I see are illusions; I believe that nothing has ever existed of everything my lying memory tells me. I think I have no senses. I believe that body, shape, extension, motion, location are functions. What is there then that can be taken as true? Perhaps only this one thing, that nothing at all is certain. Stephen Colbert The Late Show with Stephen Colbert There's an old saying about those who forget history. I don't remember it, but it's good. the output is: Descartes speaks: I think, therefore I am Stephen Colbert speaks: Welcome to The Late Show with Stephen Colbert Descartes gives his speech: I suppose therefore that all things I see are illusions; I believe that nothing has ever existed of everything my lying memory tells me. I think I have no senses. I believe that body, shape, extension, motion, location are functions. What is there then that can be taken as true? Perhaps only this one thing, that nothing at all is certain. Stephen Colbert gives his monologue: There's an old saying about those who forget history. I don't remember it, but it's good. 289734 1726976 qx3zqy7 LAB ACTIVITY 11.12.1: LAB: Speaker (interfaces) 0 / 10 File is marked as read only Current file: SpeakerDriver.java 1 import java.util.Scanner; 2 3 public class Speaker Driver { 1) 1 import java.util.Scanner; 2 3 public class SpeakerDriver { public static void main(String[] args) { 5 Scanner scnr = new Scanner(System.in); 4 String philoName, philosophy; String hostName, show; String speech, monologue; philoName scnr.nextLine(); philosophy = scnr.nextLine(); speech = scnr.nextLine(); hostName = scnr.nextLine(); show = scnr.nextLine(); monologue = scnr.nextLine(); Speaker phil = new Philosopher (philoName, philosophy); Speaker tsh = new TalkShowHost(hostName, show); 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 speaks: "); System.out.print(philoName + phil.speak(); System.out.print(hostName + tsh.speak(); speaks: "); System.out.println(); System.out.println(philoName + " gives his speech:"); phil.speak ( speech); System.out.println(); System.out.println(hostName + gives his monologue: "); tsh.speak(monologue); Load defau Represents a Talk Show Host @author // TODO: Implement Speaker public class TalkShowHost { private String name; private String show; 1 2 * 4 * /** * Full parameter constructor for Talk Show Host @param name the name of the Talk Show Host @param show the name of the show the Talk Show Host Hosts */ public TalkShowHost(String name, String show) { this.name = name; this. show = show; } 6 7 8 9 0 1 22 23 24 25 26 27 28 29 30 31 32 33 * Returns the name of the Talk Show Host. * @return the name of the Talk Show Host. */ public String getName() { return name; } 7** Updates the name of the Talk Show Host. @param name the name of the Talk Show Host. public void setName(String name) } 35 36 37 38 39 40 41 /** * Returns the name of the show that the Talk Show Host is on. * @return the name of the show. public String getShow() { return show; } /** Updates the show that the Talk Show Host is on. @param show */ public void setShow(String show) { this.show = show; } 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 /** * Returns a String representation of the Talk Show Host. * @return a string representing the Talk Show Host. */ @Override public String toString() { return "TalkShowHost" + "name=" + name show=" + show + '}'; } + " /** * Prints out the monologue of the Talk Show Host. * @param speech the text of the monologue */ * Returns a String representation of the Talk Show Host. @return a String representing the Talk Show Host. */ @Override public String toString() { return "TalkShowHost{" + "name=' show=" + show + '}'; } + name + 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 /** * Prints out the monologue of the Talk Show Host. @param speech the text of the monologue public void monologue(String speech) { System.out.println (speech); } /** * Prints out the Talk Show Host welcome message. */ // TODO: Implement the speak() method Should print "Welcome to" plus the name of the show /** * Prints out the speech for the TalkShowHost. @param speech the speech to print. */ // TODO: Implement the speak() method Should call the monologue() method Current file: Speaker.java 1 // TODO: create Speaker interface // TODO: declare speak() method with no parameters, returns void 2 3 4 5 6 7 8 // TODO: declare speak() method with a string parameter, returns void My library > CSCI 1082: Object-Oriented Programming home > 11.12: LAB: Speaker (interfaces) 1 /** 2. * Represents a Philosopher 3 * @author your name> 4 */ 5 6 // TODO: Update class to implement Speaker interface 7 public class Philosopher { 8 private String name; 9 private String philosophy; 10 11 12 * 13 14 15 16 17 18 19 * Returns the name of the Philosopher @return the name of the Philosopher */ public String getName() { return name; } /** 20 * Updates the name of the Philosopher. @param name the new name of the Philosopher. public void setName(String name) { this.name = name; } 21 22 23 24 25 26 27 28 29 30 31 32 33 /** * Returns the philosophy of the Philosopher. @return the philosophy of the Philosopher. public String getPhilosophy() { return philosophy; } 5 6 7 -8 59 10 41 42 13 44 45 * Updates the philosophy of the Philosopher. @param philosophy the new philosophy of the Philosopher. */ public void set Philosophy (String philosophy) { this.philosophy = philosophy; } 46 47 48 * Full parameter constructor for Philosopher. * @param name the name of the Philosopher. */ public Philosopher(String name, String philosophy) { this.name = name; this.philosophy - philosophy, } 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 * Representation of a Philosopher * @return a string representing the Philosopher. */ @Override public String toString() { return "Philosopher{" + "name=" + name + '}'; } /** Prints the Philosopher's philosophy 1 TODO: Tmplement no-narameter sneak() method My library > CSCI 1082: Object-Oriented Programming home > 11.12: LABA: Speaker interfaces) @param name the name of the Philosopher. */ public Philosopher (String name, String philosophy) { this.name = name; this.philosophy - philosophy; } 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 Representation of a Philosopher @return a String representing the Philosopher. * @Override public String toString() { return "Philosopher{" + "name=" + name + '}'; } 62 * Prints the Philosopher's philosophy */ // TODO: Implement no-parameter speak() method 77 The method should print the Philosopher's philosophy 63 64 65 66 67 68 69 70 71 72 73 74 /** * Prints out the speech for the Philosopher. * @param speech the speech to print. // TODO: Implement the speak() method 17 The method takes a string speech // The method should print the speech 75 76 78 79 ]

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

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

9. Identify four interaction styles in intercultural marriages.

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago