University of Toronto - Fall 1996
Department of Computer Science

CSC 148H: INTRODUCTION TO COMPUTER SCIENCE



Old Announcements -- Week 4



Friday 04 October: Assignment 1 -- Keeping the crosswalk open

The algorithm given in the assignment handout says that each time the crosswalk is open, it will stay open for at least one more time step so that some students can cross. Nothing in the algorithm explicitly makes this happen; it is merely a side effect of the algorithm, as long as the keep-crosswalk-open threshold is lower than the open-crosswalk threshold.

When reading the system parameters, the program could check that the keep-crosswalk-open threshold is indeed lower than the open-crosswalk threshold. However, the program does no error checking at all on the the system parameters. Don't worry about adding such checks, or including code to ensure that the crosswalk will stay open for at least one more time step so that some students can cross. Just assume that the system parameters have sensible values.



Friday 04 October: Assignment 1 -- Fixing the removeElement bug

In a posting yesterday, I wrote that procedure removeElement has a bug in it, and that you should fix it when you change the StudentSet module in Part A of the assignment. In fact, the changes you make when modifying the StudentSet module to use the mark-as-deleted approach may have the side effect of eliminating this bug for you.

Thursday 03 October: You need photo ID

Students without photo ID cards: please read this notice. And make sure you get a card before you try to write any exams!

The Faculty of Arts & Science wants everyone to know about these hours for issuing student photo identification cards:

        Tuesday, October 22, 1996
        Wednesday, October 23, 1996
5 - 7 p.m. in Room 562, Sidney Smith Hall (Ground Floor). These hours are in addition to the regular hours of Monday and Wednesday, 9 a.m. - 12 noon, and Thursday 2 - 5 p.m.

(If you're not in Arts & Science on the St. George campus, this doesn't apply to you.)



Thursday 03 October: Assignment 1 -- Changing the starter code?

Question: Can we change the starter code?
Answer: There is no need for you to change the starter code at all, except to do the things required in Part A: add Simulate.run (and any subprograms it needs) to the Simulate module, and then modify the StudentSet module in the two ways we describe.

If you want to change the starter code, you must ask Diane to approve your change. (This is so that we can prevent students from going off on the wrong track.) There is one exception: you may add to the Performance module without Diane's approval, if you want to gather additional information for your experiment in Part D. If you do this, you must hand in a printout of your modified Performance module (with your additions highlighted).



Thursday 03 October: Assignment 1 -- Details of the crosswalk algorithm

Question: It seems from the sample run that when the crosswalk is closed, and the open crosswalk threshold is exceeded on a certain step, that the walkers don't cross until the next step (see steps 3-4 in the big sample run). Why don't they cross on the current step?
Answer: That's just not how this crosswalk works. (Imagine that there is a gate that has to go up before students can cross, and that the opening of the gate takes some time.)
You could imagine other algorithms for a crosswalk, including better ones. But your assignment is to implement the algorithm given. Don't change it.

Question: In the long sample run, during step 7 the crosswalk is closed to pedestrians. You would think that cars could then go through in step 8, since there are some cars waiting. But during step 8, the crosswalk opens again, so no cars get through! Isn't this silly?
Answer: Yes, you could argue that this is a bad feature of the crosswalk algorithm. But it is indeed what the algorithm says to do. Don't change the algorithm.
This points out one use of a simulation: if the system you are simulating is very complex, you may not notice a "feature" such as this until you run the simulation and observe what happens.

Question: I know the number of waiting cars that drive through is determined by how many steps have elapsed since the crosswalk was closed to pedestrians. What if this is just step 1, let's say, ten cars arrive, can they all pass at the same time without waiting, or only 1 car can pass, then 2 cars can pass at step 2, and so on, assuming the cross walk keeps closed?
Answer: Treat the 1st time step the same as any other. This means that even if 10 cars arrive, only 1 can go through on that time step (unless the crosswalk opens to pedestrians, in which case no cars go through).
This makes sense if you imagine that the simulation starts after the crosswalk has just closed to pedestrians (and thus just opened to cars).



Thursday 03 October: Assignment 1 -- CarQueue.clear

Question: Why is procedure clear not exported from module CarQueue? How can I call it in module Simulate?
Answer: You don't actually need to use CarQueue.clear in your simulation (and in fact, I can't think of a way in which you could make use of it in your simulation). What you will use for taking cars out of the queue is CarQueue.dequeue.

But you have pointed out a mistake: I meant to export clear from CarQueue and did not. You may add it to the export list if you wish.



Thursday 03 October: Assignment 1 -- StudentSet.removeElement

Question: Procedure removeElement is exported from StudentSet, yet I can't find a way to use it. Am I missing something?
Answer: No. You will not need to use all of the subprograms provided to you by the various modules. Procedure removeElement (and others) is included so that we'll have complete and coherent modules, quite independent of the particular uses to which they will be put in this program.

Note that procedure removeElement has a bug in it. It does not work for removing an element from the front of the linked list. Fix this when you change the StudentSet module in Part A of the assignment. Hint: Look at the delete procedure on lecture slide 88.



Thursday 03 October: Assignment 1 -- "unit" in OOT

Question: What's a "unit"?
Answer: A single module in a file by itself is a unit. If you want to put a module into a separate file by itself and import it where needed, you must declare the module to be a unit.

It is convention to use the file extension "tu" ("turing unit") when naming the file that stores a unit.



Thursday 03 October: Assignment 1 -- More about "opaque"

Question: If an item is not declared opaque, can the user access its guts (like the "Name" field in studentType) from the outside of the module?
Answer: Yes. We export types opaque to prevent exactly this sort of thing.

Question: This question refers to the BigInt example used in tutorial this week. Outside the module, can we perform:

     var temp : BigInt.BigIntType
     temp := BigInt.multiply (num, num)
Is it really legal to perform an assignment to temp outside the module when its type BigIntType is exported opaque?
Answer: Yes, it is legal. Doing an assignment in this manner does not violate the idea of hiding the type -- you don't have to know the type in order to be able to do such an assignment, and the assignment will still work even if the type inside the module is totally changed. But if this sort of assignment bothers you, it can be avoided by using a procedure (with a var parameter) instead of a function. A procedure could do the assignment for you.

Tuesday 1 October: Assignment 1 -- "export opaque"

In the Stud module, StudentType is exported "opaque". (Note that in our code, the keyword "opaque" applies only to StudentType, not to the rest of the export list.) As the comments in the code explain, specifying that StudentType is exported opaque means that the user of the module is allowed to create variables of StudentType and pass them around, but to do nothing else with them. If the the value of such a variable is to be examined or changed, an exported routine from the Stud module must be used. CarType, defined in module Car, is analogous.

The keyword opaque can be used only in an export list, and can only be applied to a type; it cannot be applied to a subprogram.

You will not find "opaque" mentioned in the BHH text, probably because it is not considered the best way to create multiple instances of something. The ideal method is to use a class; we'll learn about this later in the term.



Tuesday 1 October: Assignment 1 -- Output

Question: What kind of output should we be producing if the flag for "report every event" was set to false?
Answer: If "report every event" is set to false, then your output should not include any of the tracing output, such as "No students arrive at this time step", that would otherwise be produced with each time step. Your output should include only the state summaries (unless the state reporting frequency has been set to 0) and the final statistics.

Tuesday 1 October: Mail and news on the PCs

Question: The current netscape in our computer lab doesn't specify the mail host in "Preference". As a result, e-mail can't be send from netscape, and posts to the news group are also forbidden. Is there any way we can find out the name of our mail host?
Answer: For mailing, use Pegasus mail instead of Netscape. To post to a newsgroup, use Pegasus to mail your posting to the newsgroup. For example, if you want to post a message to our course newsgroup, just send mail containing the text of your message to ut.cdf.csc148h

Note that ut.cdf.csc148h is the correct name for our course newsgroup. The course information sheet gives an out-of-date name for the newsgroup.



Tuesday 1 October: Print quota on the PCs

Question: There is an icon to check for disk quota, but not for print quota. Is there any way we can check our print quota?
Answer: There is not currently a way to check your print quota. If you are sensible with printing, you won't run out.

Tuesday 1 October: PC restrictions

Question: I was wondering whether or not we have the capability to access our e-mail accounts from home, such as by dialing up via telnet.
Answer: The PCs are not accessible to you remotely. You can only use them by physically being in the lab.
Question: Does our e-mail account allow us to receive and send e-mail to anyone anywhere, or is it strictly limited to U of T students and staff?
Answer: You can send email anywhere and receive it from anywhere.
Question: Are we allowed to make home pages with our accounts?
Answer: You can, but you'd be the only person on the planet who could read it. Not very useful. :-)

These restrictions are intended to protect students' ability to get their csc coursework done. If the lab provided tools that were just for fun or only useful for purposes other than doing csc coursework, it would be overflowing with people, and students would have trouble getting on the machines to do coursework.

When you start taking 200-level courses, you will be using a different lab with almost no such restrictions.



Tuesday 1 October: Font sizes in the OOT environment

Question: Can we change the font size in the OOT edit window?
Answer: Yes. Edit the file "oot.ini" (which will be on the X drive if you're working in the PC lab). You will find lines specifying the editor font height (probably set to 15 by default) and the editor font width (probably set to 8 by default). You can change these to get a larger or smaller font. Changing the font size in the run window is analogous.


Back to the csc148 home page