Check here for updates on this lab.
This lab is intended to give you practice reading code that others have written, including debugging that code. You should do this lab with a partner. Individuals who wish to work alone must get permission from their instructor. Only a single group of three will be allowed in any section of the course. Collaborate with some one in your section only.
This lab illustrates
This lab gives you practice in the following:
Creating sophisticated graphics from scratch in any programming language requires a complex program. Java object classes help to control the complexity of the task by doing much of the work for you. For this lab you will be introduced to the barest of fundamentals so that you can begin to draw graphics. The intent is not merely to introduce you to some fun programming, but to give you practice in the valuable skills listed above.
Chapter 4 of Koffman and Wolz provides an introduction to the concepts in this lab. Page 163 contains a summary of the AWT graphics methods you will need. In order to focus on graphics, we will use applets rather than applications for this lab. Recall that you run an applet with the appletviewer rather than with the java interpreter. The .html file is the argument for the appletviewer. You may also run applets from a browser by visiting the .html page that contains the applet. More "hints" and help on html are provided in the Hints section below.
Some of the steps below contain specific tasks for each partner in a pair. Assign partner 1 and 2 at the start and stick to the assignment. Check each other's work. Groups of three: attempt to distribute the work evenly. Each member should participate in each step.
All files and directories referenced here can be found in ~psjava/Lab3/
Partner 1: Modify the code so that the two squares are centered at the point 100,100. The inner red box should have height and width of 50 pixels, the black square should have height and width of 70 pixels. Name the file Squares1.java. You will have to create an .html file to view it.
Partner 2: Adapt the code from partner 1 so that the center point and the sizes of the squares are all declared as datafields. (e.g. the draw methods will refer to datafields rather than to literals such as 50 and 100.) Use datafields and local variables judiciously. Call this one Squares.java. You will be able to use the original html file to view it.
Together: Write two more versions of the applet: one that shows squares of size 100 and 200 with their center at location 100, 100; the second one that shows squares half as big at location 50,50. Name your applets Squares2 and Squares3. Use the html file ManySquares to display all three applets at the same time!
Each partner should do his/her assigned task. If a partner gets stuck the other may help out, but under no circumstances should one partner do "all or most of the programming."
Create a web page that points toward each of your solutions. On each solution page include the applet as well as the source code. Do not place the applets for each task on a single page, link separate pages via an organizational page that identifies the programmers, the lab, the course etc.. Each "task" page should include a summary of the task, with full identification.
Submit a paper lab report during your class meeting on the due date. Submit only one report per partnership. The lab report should be produced on a word processor. Staple the completed report in the upper left corner. Do not use a report cover. The lab report should include in order:
You can begin this lab without extensive knowledge of the AWT graphics functions. We will review these in class on Friday, September 24, but you will need to read Chapter 4 carefully to complete step 5.
ASK!!!!!!! your professor questions, in class, in lab, during office hours and especially via email. Please do not phone.
Don't know how to create a web site at TCNJ? Check out the following page: http://www.tcnj.edu/~im/tsnet/tsnet.html. Note that all files that are to be accessed by the outside world must have their protection value set to 755. Compiled class files ( *.class) do not get this value from the compiler. You must set it by hand. Make sure you are in the folder that contains the .class files and type: chmod 755 *.class (note that your folder must be within your /www/ folder for outsiders to access the applets from the web. Separate pages give information on html and file protections. Enjoy!
You may get help from classmates, tutors and other students outside your team on system technicals, syntax bugs, and small issues related to the Java language. Get help from anyone you can on how to print in the labs, how to move files from Mac to PC to Unix and back, how to add code to a word processing file, how to transfer a Word document written on a Mac to a PC and back.
You may NOT get help from the above groups to develop the solution to a task, to debug the code in task 3, or to implement your solutions in the other tasks. Other than your partner, no one may help you write, or debug your code except for times when you "simply cannot see what is wrong". If you cannot complete a task see your professor during lab, during office hours or send email.
The due date is considered the "last possible" moment to submit a report. You should be able to complete this project in a week if you distribute the work evenly between lab partners. A "down" system on the morning the lab is due will not cause an extension of the due date. Other universal calamities may be negotiated with the entire class. The point: hand SOMETHING of worth (e.g. the first few steps) in by the due date.