Try writing a solution to this?
Jason Clinton
me at jasonclinton.com
Tue Jun 21 12:56:29 CDT 2005
On Tuesday 21 June 2005 11:32, Jason Clinton wrote:
> The problem statement is modeled by a fairly simple 5 state machine. Here's
Someone asked what a state machine is. In a nutshell, it's a way of listing
all the states that a program might be in during its lifetime and how you
move from one state to another.
And for anyone that decides to give their favorite language a crack at this,
there are actually 2 states and 5 possibilities that you must consider:
Given that a Boolean variable named "THERE'S_MORE_LINES" exists then
THERE'S_MORE_LINES = false and line doesn't match criteria
THERE'S_MORE_LINES = false and line matches and has header terminator
THERE'S_MORE_LINES = false and line matches and doesn't have header terminator
THERE'S_MORE_LINES = true and line doesn't have header terminator
THERE'S_MORE_LINES = true and does have header terminator
The initial state is THERE'S_MORE_LINES = false.
So if you want to draw this out draw two circles which represent the value of
THERE'S_MORE_LINES and write True in one and False in the other. Then draw an
arrow line for each of the 5 possibilities above. If the possibility doesn't
change THERE'S_MORE_LINES, then draw an arrow line that starts at either the
True or False node and loops around back in to it.
For instance, if the case is "THERE'S_MORE_LINES = false and line matches and
doesn't have header terminator" then you draw a line from false to true.
If it's "THERE'S_MORE_LINES = false and line matches and has header
terminator" then you draw a loop from false to false.
CS people tend to draw an arrow line labeled "Start" pointing to the initial
state of the machine.
Then, you pick your favorite language and ensure that the code handles all the
lines (possibilities) in your drawing.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://kclug.org/pipermail/kclug/attachments/20050621/42e39380/attachment.pgp
More information about the Kclug
mailing list