which sends the String "examine" to the handle(String s) method of a book item in the room. It does so by chopping the first and last words of the string "examine book." So if we typed "examine the huge green magic book" it would still only send the word "examine" to the handle(String s) method of the book.
Now we need to be able to have an Item named "huge green magic book" So if we type:
examine huge green magic book
and there was a huge green magic book in the room, the word "examine" would go to the handle(String s) method of the huge green magic book.
As a general strategy, start looking for matches from the right. So we would look for matches for, in order:
book
magic book
green magic book
huge green magic book
For now, don't try putting a book and a huge green magic book in the same room. We will deal with that complication later.
Right now, commands can only take the form
examine book
which sends the String "examine" to the
handle(String s)
method of a book item in the room. It does so by chopping the first and last words of the string "examine book." So if we typed "examine the huge green magic book" it would still only send the word "examine" to thehandle(String s)
method of the book.Now we need to be able to have an Item named "huge green magic book" So if we type:
examine huge green magic book
and there was a huge green magic book in the room, the word "examine" would go to the
handle(String s)
method of the huge green magic book.As a general strategy, start looking for matches from the right. So we would look for matches for, in order:
book magic book green magic book huge green magic book
For now, don't try putting a book and a huge green magic book in the same room. We will deal with that complication later.