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 1: Strings and String Methods in Java:
Take the given example codewhich is part of a simple conversatio(n)/(m)essaging 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 1: 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 3 or 4 sentences and then have to name a topic those same 3 or 4 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 2: 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 stor(e)/(s)ave the variables for later, but keep in mind that later we will need to retrieve them.
Bonus 5-(10)/(%): include some basic math for the integer type variables (make sure you indicate this on the submission page if you want credit)
Objective 3: 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 >=1>>[[Your cheers are greatly appreciated -> Yes]]
> ::Start
Hello
How can I help you
[[Loops]]
[[If_(S)tatements]]
[[end]]
::Loops
There are 3 kinds of loops which would you like to know about?
[[For]]
[[While]]
[[DoWhile]]
::For
The for loops looks like:
for (int i=0;i10;i++)
This will run 10 times
[[Start]]
::While
The while loops looks like:
int i=0;
while (i++10)
{
}
This will run 10 times
[[Start]]
::DoWhile
The do while loops looks like:
int i=0;
do
{
}
while (i++10);
This will run 10 times
This is the only postfix loop structure
[[Start]]
::If_(S)tatements
Ooo, If statements are fun. They can evaluate a condition and select a line of code to run
[[More_(I)f_(S)tatements]]
::More_(I)f_(S)tatements
If statements are classified as selection statements.
Other forms include the switch statement and the short-hand-if, or tertiary operator.
[[Start]]
: : end
Goodbye
String and Regex Lab Part 1 : Strings and String

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!