Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

-Task 4.3 Well that was pretty tedious. So let's simplify things a bit. We are going to combine all three robots into a single Robot

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
-Task 4.3 Well that was pretty tedious. So let's simplify things a bit. We are going to combine all three robots into a single Robot class. The Robot class is already started for you. Do not change what is already there, just add what is missing; once again copy-paste is your friend. Some things to note: 1. In Robot.java , we want all of the constructors from before (there are 3). 2. The underlying behaviour should be the same. I.e. every instance of the Robot class should have a speak(), friendspeak (), makeFriend() method as before. 3. After you complete the Robot class, make three Robots in Main.java and make them all friends as in 4.2. 4. Finally, print out the complete verse as in 4.2. You can use the supplied lines in Main.java as those are the lines expected as the output for this task. Your code should do exactly the same thing as before. Oublic class Main { A3 X2 AV public static void main(String[] args) { String Line1 = "You ain't nothin' but a hound dog, cryin' all the time"; String Line2 = "Well, you ain't never caught no rabbit and you ain't no friend of mine": String Line3 = "Ah thank you, ah thank you very much"; // create Robots here as in 4.2 // print the verse in the right order here } I } Se Tools Ves Window Help Lab 2.- More Objects. Constructors Scodes min) 4.2) RobotOne njava RobotOne jave Robotjava x public class Robotone { Add Configuration. private String name // nane of Robotone // lines Robot One knows private String lang "You ain't nothin' but a hound dog, cryin' all the time"; private Robot Two Trion = null; // Robotone's friend /** * Constructor for RobotOne, takes the name, default values are already specified above. public RobotOne(String nane) Kthis.name = name; @ * Give RobotOne a friend. public void makeNewFriend (RobotTwo robotTwo) { friend robot Two; /** */ public * Set Robotone to say something it knows. Ing speak() { return line; 1:1 U ollease take a moment to share your experience and help us make learning Java better. (46 minutes ago) GA BOL Tools VCS Window Help Lab 2 - More.Objects Constructor Sep 2) 42 ste RobotTwo Add Configuration ava Robotonejava RobotTwojava Robotjava public class Robot Two { private String name // name of Robot Two // lines Robot Two knows private String Line - "Well, you ain't never caught ne rabbit and you ain't no friend of mine"; private RobotOne friend = null; // Robot Two's friend 0 3 . /** * Constructor for RobotTwo, takes the name, default values are already specified above. */ public Robot Two(String name) { this.name = none; /** * Give RobetTwo a friend. public void makeFriend (Robotone robotone) { friend = robotone; 3 3 * Get Robot Two to say something it knows. / public String speak() { return Line: 3 21 LF ease take a moment to share your experience and help us make learning Java better. (46 minutes ago) Run Tools VCS Window Help Lab 2.. More Object Constructor Scope again) 42 ) Robotthree Wainjava Robotnej RobotTwojava Robothree public class RobotThree Add Configuration Robotjana private String nang: 1/ name of Robot Three // Lines Robot Three knows private String Line - "Ah thank you, ah thank you very much"; private Robotone friend null; // Robot Three's friend 0 Constructor for Robot Three, takes the name, default values are already specified above. public RobotThree(string nane) this.name.name; /** M @ . Give Robot Three a friend. public void makeFriend (Robotne robotone) friend rebotone; */ Rel GI 0 /* CHA 2,3 Oy Get RobotThree to say something it knows. pubille String speak() { return Line: One 16h . > Are Inc Compi Faled Er 11 LF U space Please take a moment to share your experience and help us make learning av bete (47 minutes ago -Task 4.3 Well that was pretty tedious. So let's simplify things a bit. We are going to combine all three robots into a single Robot class. The Robot class is already started for you. Do not change what is already there, just add what is missing; once again copy-paste is your friend. Some things to note: 1. In Robot.java , we want all of the constructors from before (there are 3). 2. The underlying behaviour should be the same. I.e. every instance of the Robot class should have a speak(), friendspeak (), makeFriend() method as before. 3. After you complete the Robot class, make three Robots in Main.java and make them all friends as in 4.2. 4. Finally, print out the complete verse as in 4.2. You can use the supplied lines in Main.java as those are the lines expected as the output for this task. Your code should do exactly the same thing as before. Oublic class Main { A3 X2 AV public static void main(String[] args) { String Line1 = "You ain't nothin' but a hound dog, cryin' all the time"; String Line2 = "Well, you ain't never caught no rabbit and you ain't no friend of mine": String Line3 = "Ah thank you, ah thank you very much"; // create Robots here as in 4.2 // print the verse in the right order here } I } Se Tools Ves Window Help Lab 2.- More Objects. Constructors Scodes min) 4.2) RobotOne njava RobotOne jave Robotjava x public class Robotone { Add Configuration. private String name // nane of Robotone // lines Robot One knows private String lang "You ain't nothin' but a hound dog, cryin' all the time"; private Robot Two Trion = null; // Robotone's friend /** * Constructor for RobotOne, takes the name, default values are already specified above. public RobotOne(String nane) Kthis.name = name; @ * Give RobotOne a friend. public void makeNewFriend (RobotTwo robotTwo) { friend robot Two; /** */ public * Set Robotone to say something it knows. Ing speak() { return line; 1:1 U ollease take a moment to share your experience and help us make learning Java better. (46 minutes ago) GA BOL Tools VCS Window Help Lab 2 - More.Objects Constructor Sep 2) 42 ste RobotTwo Add Configuration ava Robotonejava RobotTwojava Robotjava public class Robot Two { private String name // name of Robot Two // lines Robot Two knows private String Line - "Well, you ain't never caught ne rabbit and you ain't no friend of mine"; private RobotOne friend = null; // Robot Two's friend 0 3 . /** * Constructor for RobotTwo, takes the name, default values are already specified above. */ public Robot Two(String name) { this.name = none; /** * Give RobetTwo a friend. public void makeFriend (Robotone robotone) { friend = robotone; 3 3 * Get Robot Two to say something it knows. / public String speak() { return Line: 3 21 LF ease take a moment to share your experience and help us make learning Java better. (46 minutes ago) Run Tools VCS Window Help Lab 2.. More Object Constructor Scope again) 42 ) Robotthree Wainjava Robotnej RobotTwojava Robothree public class RobotThree Add Configuration Robotjana private String nang: 1/ name of Robot Three // Lines Robot Three knows private String Line - "Ah thank you, ah thank you very much"; private Robotone friend null; // Robot Three's friend 0 Constructor for Robot Three, takes the name, default values are already specified above. public RobotThree(string nane) this.name.name; /** M @ . Give Robot Three a friend. public void makeFriend (Robotne robotone) friend rebotone; */ Rel GI 0 /* CHA 2,3 Oy Get RobotThree to say something it knows. pubille String speak() { return Line: One 16h . > Are Inc Compi Faled Er 11 LF U space Please take a moment to share your experience and help us make learning av bete (47 minutes ago

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

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

calculate area of parallelogram c program

Answered: 1 week ago

Question

How many multiples of 4 are there between 10 and 250?

Answered: 1 week ago