CS 10, Spring 1998
Lab 4.5: The Super Duper Quaker Datemaker
or
CS10's Attempt to Improve the Swarthmore College Dating Scene
Assignment for the Next Lab
- Read pp. 170-178 and pp. 183-187
- For discussion, view video 4 of "The Machine That Changed the World"
The purpose of this lab is help you develop an application from the initial design stage through to completion. This lab will give you the chance to synthesize the HyperCard authoring and scripting skills you've been learning this semester. The application we will develop is the Quaker Datemaker.
What is the Quaker Datemaker?
The Quaker Datemaker will be an application which matches a student with other students who have expressed an interest in dating him or her. The idea is that each student who participates in the datemaker will submit a list of students which he or she would like to date. After submitting a list of students he or she would like to date, each student then gets back a list consisting of only those students who included the original student on their list, and who the original student included on his or her list. So each student gets back a list consisting of exactly those students who he or she would like to date, and who would also like to date that student.
Design Summary
The stack will contain one card for each student who submits a list. The card representing a student will contain one field which will store information about the student (the student's name, email, etc), one field which will store the student's list of desired dates, another field which will store the list of dates which the student will get back, and a button which will create this list. In addition to the student cards, there will be a main card which will be the first card in the stack, and which will allow allow the stack's user to find a student's card by entering their name in a field and clicking some button.
The Details
Authoring
- Begin by setting up the stack. Open a new stack, and call it "The Quaker Datemaker." The current card will be the stack's home card, which welcomes the user to the stack, and which will allow the user to search for the card representing a particular student.
- Add a field welcoming the user to the stack. Add some graphics, drawings, or any other effects to spruce up the card.
- Add a field where the user can enter the name of a student.
- Near this field, add a button called "find". Later, we'll write a script for this button which will find the card representing the student whose name the user enters in the field we just created.
- Add a field which explains to the user that he or she can enter the name of a student in the field you just created, and use the find button to go to that student's card.
- Add a quit button to this card, and fill in the appropriate script.
- Now let's create the student cards. These cards will all share the same background, which will contain fields for the students' personal information and lists of dates, and a button which will create the list of the student's matches. Since the student cards will all share the same background, we'll need to create a new background.
- Create a new background. Creating a new background automatically creates a new card with that background, so now our stack consists of two cards, each with a different background.
- On this background, create three fields.
- Call one field "personal info." This will contain information about the student-- name, email, etc.
- Create another field called "desired dates." This field will contain list of desired dates submitted by the student.
- Create a third field called "matches." This field will contain the list of matches for the student, i.e. the list of dates which the student will get back.
Create three new fields which will provide labels for the fields you created above. These three new fields will contain the text "Personal Information", "Desired Dates", and "Matches." In order to be able to enter this text into the background, you'll need to select the "share text" property when you get the "field info"
- On this background, create the following new buttons:
- Create a button called "Find Matches." Later, we'll write a script for this button so that when the user clicks this button, the "matches" field will be filled in with the appropriate list of matches.
- Create a button which will take the user back to the first card in the stack.
- Copy and paste the quit button from the first card.
- Create a button that will take the user to the next card in the stack.
- Create a button that will take the user to the previous card in the stack.
- Leave the background, and go back to the student card, if you're not there already. Now that we've created a background for each student card, let's create 5 new cards. Our stack should now contain six student cards, all sharing the same background.
- Go through each student card and fill in the "personal information" and "desired dates" fields.
- The "personal information" field should contain the student's name on the first line, and the student's email address on the second line, and any other information which might be useful on the remaining lines.
- The "desired dates" field should contain the name of one student per line. Fill in some hypothetical desired dates for each student.
- Leave the "matches" field empty for now, since it will be the job of the "Find matches" button to compute the appropriate list of matches.
Scripting
- Start by writing the script for the "find" button on the stack's first card. You can determine the number of cards in your stack by using the expression "number of cards". Writing the script for this button will probably be easier if you start by writing an algorithm (an English solution) for solving the problem. If you're stuck, try implementing the following algorithm:
- for each student card in the stack (that is, for each card beginning with card number 2)
- Compare the first line of the "personal information" field to the first line of the "find" field. If they're equal, put the card number into a variable called whichCard.
- go to whichCard
- Now we need to write the script for the "matches" button. Before writing the script for this button, start by writing, in the stack script, a function handler called "wantsToDate." This function handler will be used to determine whether a student appears on another student's list of desired dates. This function will take two arguments, a card number (which is the card number of some student), and the name of some other student. So the skeleton of the function handler will look like:
function wantsToDate cardNum, name
end wantsToDate
It will check whether the name passed to it appears in the list of desired dates for card number cardNum. If the name does appear in the list of desired dates for card number cardNum, the function should return true, otherwise it should return false. Write this function, and try testing it from the message box. For example, suppose you want to know whether Sue appears in the list of desired dates on card number 3. Then after writing your function wantsToDate, you should be able to type the following into the message box:
and the value "true" will be returned if Sue does appear in the list of desired dates on card 3, and the value "false" will be returned if Sue does not appear in the list of desired dates on card 3.
- Now use the function wantsToDate to write the script for the button "Matches." This will probably be easier if you start by coming up with an algorithm (an English solution) for the problem. If you're stuck, try implementing the following algorithm:
- Store the name of the student for whom we're looking for matches in a variable called "studentName."
- Erase whatever was previously in the student's list of matches.
- For each student card in the stack (that is, for each card beginning with card number 2)
- Use the function "wantsToDate" to check if studentName appears in the list of desired dates.
- If studentName does appear in the list of desired dates, then put the name of the student represented by the current card after studentName's list of matches.
- When you've got everything working, call one of us over and show us your stack. If there is still time remaining, try implementing the following additional features:
- If there were 100 students in our stack, it fairly time-consuming to have to go through each card and click the "matches" button to compute the list of matches for each student. Add a button to the first card that will automatically compute the matches for each student in the stack. (Hint: use "send mouseUp . . .")
- You might want to deliver to each student in the stack a hard copy of their list of desired dates and their list of matches. You could get a hard copy by printing out the student's card. Add a button to the background of the student cards that will print the current card.
- Add a button the first card of the stack which will print a copy of each student card in the stack.
- Modify the matches button so that if no matches are found, a consoling message is printed in the matches field.
- Modify the matches button so that the number of matches is also displayed. For example, if the given student had 8 students on his desired date list, and was matched with 2 students, then matches field would contain the text "You were matched with 2 out of your 8 potential dates"
- Modify the matches button so that each line of the matches field contains both the name and email address of each matched student.