CSC 171
Homework assignment 2

Fall, 1998

In class:

Downloading from panther

Using the WS_FTP program on Windows, connect to panther (hostname: panther, userid: csc171, password: the one I gave out in class). The left hand side of the WS_FTP window represents the folders and files on the Windows computer in front of you, while the right hand side represents the folders and files on panther. In the left hand side, navigate to your personal folder within C:\users. In the right hand side, from the csc171 folder, open the class_dir folder, then downloads. Click with the right mouse button on buggles, and you should see a menu of several things you can do with it. Choose "Transfer folder", confirm that you really want to do that, and the entire "buggles" folder will be transferred from panther to the Windows machine. Now you can close the WS_FTP program; you won't need it for a while.

Uploading from Windows to your panther account

You can also use WS_FTP to save your own files on your panther account, so no matter which Windows machine you sit down at, you can still get to them (and nobody else can mess with them). The hostname should still be panther, but this time the userid and password will be yours. In the left hand side of the window, navigate to wherever you've put the files on the local machine (e.g. your personal folder within C:\users). In the right hand side, navigate to wherever within your panther account you want to put them: at first, you may just use your home directory, but later, as you accumulate more files, you'll probably want to sort them into folders. To transfer a single file from Windows to panther, double-click on its name on the left side of the screen. To transfer a whole folder full of files, point at its name on the left side of the screen and use the right mouse button (as in the previous paragraph) to choose "Transfer Folder".

To transfer files back from panther to a Windows machine, so you can work with them easily, make exactly the same connection, but choose the names of files and folders from the right side instead of the left.

The Buggles World

Once you've downloaded the buggles folder, get out of WS_FTP and start CodeWarrior. From the File menu, choose "Open...", navigate into the buggles folder you just downloaded, and open the file named "BuggleCS". The project window should contain two folders: "Sources" and "Classes". Ignore the latter for now. Inside the "Sources" folder should be three files: BuggleCS.html, BuggleCS.java, and BuggleWorld.java. The first is a minimal Web page that simply runs the BuggleCS applet. The second is where we'll do our work, and the third (and longest) is the definition of Buggles, BuggleWorlds, BuggleExecuters, etc. -- which you don't need to understand yet. Anyway, you can look at any of these three files by double-clicking on its name in the project window.

Close those files, so that you can see the project window. Near the top of the project window is a row of five buttons, side by side: one has a red check mark, one has an envelope, one has an arrow pointing to the right, etc. The one that looks like an envelope is the "Make" button: it will compile your program and check it for syntax errors, but not run it. The button with the right-pointing arrow is the "Run" button; use it when you want to run a Java program and see how it works. Try these two buttons now; if you haven't changed anything in BuggleCS.html, BuggleCS.java, or BuggleWorld.java, the program should compile and run correctly.

A window will open in Internet Explorer, and after a few seconds you should see a grid and a bunch of labelled buttons. (You may need to expand the window to fill the screen so you can see all of this at once.) The new Buggle() button creates a new Buggle at the bottom left of the grid. Other buttons cause the Buggle to move forward or backward, turn left or right, change colors, change directions, pick up or put down a paintbrush, or teleport (i.e. setPosition). Play with these for a while until you understand what happens in response to each message you can send to a Buggle.

One particular Buggle message is "run()", which replays a sequence of other Buggle messages. Try it, and you should see the effects of two different Buggles: a red one and a yellow one, following different paths.

Now close the Internet Explorer window, go back to CodeWarrior, and open the file BuggleCS.java, which contains the definition of this "run()" message. It creates a Buggle named becky, tells her to do a sequence of things, then creates another Buggle named bobby and tells him to do a sequence of things. We're going to modify this definition of the "run()" message so becky draws a red letter C and bobby draws a yellow letter S to the right of it. For now, comment out all the lines about bobby by inserting two slashes in front of them, e.g.

 // Buggle bobby = new Buggle ();
 
Make and run the program again, press the "run()" button, and you should see becky do her stuff without interference from bobby. Next, start changing the sequence of moves becky makes until she draws a letter C instead: say, three blocks wide by five blocks high. Make and run the program again, press the "run()" button, and see whether it works; if not, figure out what becky is doing wrong, go back and change the program again until it does what you want. Once becky's C is correct, uncomment bobby and write a sequence of commands for him to draw an S (three blocks wide by five blocks high, starting to the right of the C so the two letters don't touch).

To be turned in:

Olympic rings

The Buggles have started an Olympic games, and they want to draw a suitably colorful logo. Unfortunately, their grid isn't big enough (or circular enough) to draw the full five circles, so they'll just draw three squares, five blocks on a side, interlocked as follows:
                    
                    
                    
                    
                    
                    
                    
                    
                    

Your task is to modify the definition of the run() method so that three buggles draw the three rings of the Buggle Olympic logo. The buggles would prefer not to have to raise and lower their brushes, and teleportation is considered unsporting in the Buggle Olympics.

So how do the Buggles get to the right places without leaving un-wanted trails behind them?

If you downloaded the buggles folder before 2:30 PM, September 10, you've got old version of several of the files, and you should download the new versions: I recommend you use these as a starting point for Homework 2 (although if you've already written Homework 2, you're not required to go back and do it over starting with these files).
Last modified: Thu Sep 10 14:28:58 EDT 1998
Stephen Bloch / sbloch@boethius.adelphi.edu