CS 110 -- Lab 2
NOTES: in the directions on this page, commands you should type appear
in this font.
There are two primary goals of this lab session: first to further
familiarize you with development tools you are using (the Linux
Operating System and the XEmacs editor) and second, to work of
the homework assignment. You should answer the questions posed on this
page for your own purposes. However, do not hand this sheet in.
Linix:
Open a new terminal window and type each of the following
commands. Be sure you understand
what each command does and why. (Hint: read the attached "Unix cheat
sheet"). Note: "subdirectory" in Linux is the same as "folder" in
windows.
pwd
cd html
pwd
ls
ls -l
cd ..
ls
cd html
ls
cp Hello.html a.html
more a.html
ls
rm a.html
more a.html
cp Hello.html a.html
XEmacs:
Once you have completed the Linux series of commands, open XEmacs and
do the following
Note C-x means hold down the control key and hit the
'x' key. <RET> means hit the RETURN key
Hint: some tof this is explained in the "Emacs cheet
sheet" which is attached.
- C-x C-f html/a.html <RET>
- C-x k <RET>
- C-x C-f html/a.html <RET>
- C-x C-f Hello.html
- what did this just do? What happened to
a.html? How can you get back to a.html?
- Occasionally a tab will not appear, you can also get back to
a.html by entering C-x b a.html <RET>
- make sure you are seeing the buffer Hello.html (you can tell by
looking at the name near the bottom of the XEmacs screen
- C-k C-k
- C-y
- <up arrow>
- C-k C-k C-k C-k C-k C-k
- C-y
- drag the mouse over a section of text -- the text will get a grey
background
- C-w
- C-y
- drag the mouse over a section of text -- the text will get a grey
background
- <ESC>-w
- C-y
Quit XEmacs
DONE -- go on to working on homework.
Homework:
The following should give you some clues about ahow to proceed.
Note, that while this is a good start, it is not a good finish.
The variable names are lousy, there is not documentation, it only draws
one bar, ...
<>import java.awt.*;>
<>import
java.applet.Applet;><> >
<>public class OneBar
extends Applet><>
{ >
public void paint(Graphics hippo)
{
int d1 = 4;
int d2 = 12;
int d3 = 7;
int yScaleMax = 15; //
I chose this to be a little bigger than my biggest value
int barWidth = 300 /
3; // the size of my applet / 3, because I have 3 data points
float barHeight = (float)d1
/ yScaleMax * 300;
hippo.fillRect(0,
300-(int)barHeight, barWidth, (int)barHeight);
}
}