Question
public void readProgram(Scanner in) readProgram should read lines from the Scanner until there are no more lines to read. For each line, you should first
public void readProgram(Scanner in)
readProgram should read lines from the Scanner until there are no more lines to read. For each line, you should first remove any comment and then any whitespace from the beginning and end of the de-commented string. (A comment begins with the first '#' and goes to the end of the line.) If the resulting string is empty the line can be ignored. Otherwise, the modified line should be used to construct a new SimpleBotStatement object. If the modified line is an illegal program statement, the construction of the SimpleBotStatement will fail with an IllegalArgumentException. Your readProgram method should not catch this exception and instead should allow it to continue to the caller of readProgram. You should document that an IllegalArgumentException is thrown if a program is illegally formatted.
Note that readWorld and readProgram can each be called more than once, but it is always the most recent call to either of these methods that defines what the robot's world and program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started