Question: String and Regex Lab Part 1 : Strings and String Methods in Java: Take the given example codewhich is part of a simple conversatio (
String and Regex Lab
Part : Strings and String Methods in Java:
Take the given example codewhich is part of a simple conversationmessaging system. Review the code to makesure you arefamilia with the String methods that it is currently using. We aregoing to be adding more functionality to it Currently, we have Topics, that consist of atitle, somecontent, and someoptions. The user is shown the content and then the options allow the user to respond. Those responses then link to another topic. ::
Yes
Thank you stranger, we are lost in the woods. Can you help us find the way out?
Okay I can help
Find your own way
Objective : Adding decoration text
So right now what the user's response options are exactly what topic it goes to We need to have some way of saying one thing that goes to another named topic. It would be really annoying to have a player option say or sentences and then have to name a topic those same or sentences. Instead lets do something like:
Okay I can do that Accept
Now what it shows to the user is the text at the beginning but if that option is selected it will go to the Accept topic.
Objective : Adding variables
We will be adding a way to set variables based on where the user goes in the conversation. The format for how variables will be set should look something like:
We will be focusing on integer whole numbers and string datatypes. Floating or any other datatypes are not required to be implemented. I typically do not consider capitalization for either the command set or the variable name but I will leave that option upto you. You can choose however you want to storesave the variables for later, but keep in mind that later we will need to retrieve them.
Bonus : include some basic math for the integer type variables make sure you indicate this on the submission page if you want credit
Objective : Getting Variables
Now we need to add the ability to retrieve variables. So we will add a get command that looks something like:
This doesn't have a lot of utility but will be used in the next objective. It could be used to say
count the number of times you've done stuff if some simple math was added to the
variables to allow them to count This could also be used to store names like storing the
player name and getting it whenever another player said hello for instance:
:: Greet
Hello Your cheers are greatly appreciated Yes
::Start
Hello
How can I help you
Loops
IfStatements
end
::Loops
There are kinds of loops which would you like to know about?
For
While
DoWhile
::For
The for loops looks like:
for int i;i;i
This will run times
Start
::While
The while loops looks like:
int i;
while i
This will run times
Start
::DoWhile
The do while loops looks like:
int i;
do
while i;
This will run times
This is the only postfix loop structure
Start
::IfStatements
Ooo, If statements are fun. They can evaluate a condition and select a line of code to run
MoreIfStatements
::MoreIfStatements
If statements are classified as selection statements.
Other forms include the switch statement and the shorthandif or tertiary operator.
Start
: : end
Goodbye
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
