The goal for today's lab is to further understand how classes and methods communicate with each other. We'll also give our Rulers a people to rule.
Same partners, switch roles.
Start with the Conversation system as you had it last time. Fix any problems with that version. For example be sure you have all required methods in Conversation.
Make sure you add meaningful comments and have good spacing in the output. Every method should have a comment stating its purpose.
Remove any leading or trailing spaces or extraneous words like "of" when you give a ruler its name, title, and country. This may mean you need to fix the output of identify(), if so, do that now.
Always compile using javac *.java. Always run using java MainConversation.
Give each Ruler a people. Abe's people are Americans, Napoleon's are French, Cleo's are Egyptians, and so on. To do this, look at how we're currently giving each Ruler a name, title, and country, and do likewise. Print the people in identify() as in Hello world, I am Abraham Lincoln, President of the glorious Americans! You don't need to use that exact phrasing, but the message should include the name, title, and people of the Ruler. Don't remove the country variable, we'll use it later.
Add a method called sayHelloTo() to Ruler that will print something like: Hi Cleopatra this is Abraham Lincoln.
The purpose of otherName is to store the value/name of the ruler being spoken to.
Invoke this new method from Conversation. The call will look something like lincoln.sayHelloTo("Cleopatra"). In this case the program should print something like: Hi Cleopatra this is Abraham Lincoln by using the sayHelloTo() method in Ruler.
Similarly if you call this with cleo.sayHelloTo("George"), the program should print: Hi George this is Cleopatra. Note that we could send any string as a parameter: cleo.sayHelloTo("Once upon a time") will compile and run.
Add a converse method to the Conversation class. This is where all the calls to sayHelloTo should go. Make sure that each of your rulers is involved in the talking.
Now change the sayHelloTo() method so that it accepts a Ruler object as a parameter instead of a String. My parameter is now called otherRuler. So change the parameter declaration from Sting otherName to ----- otherRuler. What is the type? Reread the first sentence of #11 for your answer. Yes you can get this - don't over think.
Once you've got that, change the sayHelloTo() method to include title and country of both rulers, as in Hello, Queen Cleopatra from Egypt. This is President Abraham Lincoln and I bring greetings from America.
E-mail Conversation.java, Ruler.java and the picture of your command window to me and your partner, using subject CSCI 151_labTime_labDate_subject_name(s).
Show your running program and completed code.
Eamil and upload to Blackboard, Conversation.java, Ruler.java and the picture of your command window, if not checked during the lab.