CS 390: 61-70 Fall 1999
Homework 6 - Expert Systems& Virtual Pests, Part II

Due Date: Friday, Nov. 19 in lab


READING: 

The Analytical Engine, Chapter 9
JavaScript Goodies, Chapter 2

PURPOSE:

This is the second part of a multiple-part assignment. The purpose of the assignment is for you to gain experience with writing conditional statements, using random numbers, and using functions. For this part, you will design an HTML FORM and describe how the form will behave under different circumstances. For the second part, you will create the form and provide it with the specified behavior.

THE ASSIGNMENT:

You are required to use a word processor for all written answers.
  1. The Analytical Engine, Labs 9.1 (Part 2), 9.4, 9.5. You may find these labs on the CD that accompanies the text, or at the web site created for the text.
    As is the case in our own class labs, you are to maintain a 'lab sheet' on which you record data. If a step requires you to answer a question, record the answer on your sheet. If a step requires you to observe something, record what you observed. If a step does not require you to record anything, indicate on your sheet that you completed the step. Unlike our own class labs, you are to use a word processor to record your results.
  2. Virtual Pest problem (described below)

Virtual Pests, continued:

In the , you created a design for a "virtual pest". Your design consists of

For this exercise, you are to implement the user interface (often referred to as a front end) and submit a program design for the HTML/JavaScript code necessary to implement your virtual pest. NOTE: You do not need to complete implementation of the pest for this assignment; you need only specify the code that needs to be written, as described below.

USER INTERFACE:

You are to create a user interface you described in your previous assignment, as a web page consisting of at least one HTML form with at least two text boxes, two buttons, and a picture. You may choose to include other form elements (pop-up menus, radio buttons, etc.) for extra credit.

You need to provide a brief written description on a separate sheet of paper that describes how the interface works. Think of this as a "user manual" for your virtual pest.

You should endeavor to match the original design as closely as possible - if you have decided to change or improve your original design, you need to describe the improvements in your user manual.

PROGRAM DESIGN:

Note that you are also to provide a preliminary program design for your virtual pest. This is to be done before you try to write the code. The program design contains the names of all functions you need to provide. It also provides verbal descriptions (not "JavaScript code") for each of the functions - what does the function do, what form elements does it change values for and under what conditions?

Your program should contain a "startup" function that is invoked when the page is loaded and which sets the initial state. It should also have a "display" function that changes values of form elements as appropriate according to the state. It should have a function that investigates the current state periodically (cycling by using "setTimeout()" as explained in lecture) and makes state transitions as described in your design. It should also have a function for each button you defined, which investigates the state and makes state transitions as described in your design. Each time the state is changed, your program will call the "display" function to update the form elements as needed. For instance, for the example given with Part I, illustrated through the finite state machine and behavior table shown below, there will be the following functions:

 

Element

Type

Possible values

Meaning

Action

PetSound

text box

Grrr...
Woof woof

state=angry
state= lonely

OwnerHand

button

pat the dog

changes state to "provoked" if angry, and to "happy" if lonely.

PetAction

text box

Bite
Wag Tail

state=provoked
state= happy

...

...

...

...

...

WHAT TO HAND IN:

ACADEMIC HONESTY:

You must do this work yourself. If you need assistance with this aspect of the assignment, see a consultant during consulting hours. You are encouraged to seek any necessary help from other persons regarding how to use your computer and accompanying software, in accordance with the stated course policy.