Graphic by Keith Ohlfs

CS111, Wellesley College, Fall 1999

Frequently Asked
Questions (FAQ)
[CS111 Home Page] [Syllabus] [Lecture Notes] [Assignments] [Programs] [Documentation] [Software Installation] [FAQ] [CS Dept.] [CWIS]

When you have a CS111 question, check the FAQ first! We will try to update it frequently to respond to your common questions.

If you have a question you would like answered on this list, or if you are not satisfied with an answer that appears below, please send email to jstephan@wellesley.edu or fturbak@wellesley.edu.


Table of Contents

The following questions are linked to answers below.

The CS111 server

Symantec Cafe

Java Programming


Questions and Answers


The CS111 Server


Q: I'm having trouble using Fetch to connect to the CS111 server. What am I doing wrong?

A: There are many possible mistakes you may be making. Here are some important tips to follow:


Q: How do I navigate to a CS111 drop folder in Fetch?

A: When you connect to Fetch, you are connected to your home directory (/usr/users/your-user-name) by default. Your goal is to navigate to the CS111 drop folders, which are located in /usr/users/cs111/drop. Follow these steps:

  1. Navigate to the users directory, which is the parent of your home directory. To do this, find the pull-down menu at the top of the Fetch window. The pull-down menu always has the name of the current directory (in this case, your username) with a downward pointing triangle next to it. When you select the current directory name with the mouse, a menu of all ancestor directories will pop up. Select users.
  2. You are now connected to the /usr/users directory. Your goal is to descend to /usr/users/cs111. Do this by scrolling to cs111 in the directory listing within the main Fetch window and double-clicking on cs111.
  3. You are now connected to the /usr/users/cs111 directory. Your goal is to descend to /usr/users/cs111/drop. Do this by selecting drop in the directory listing within the main Fetch window and double-clicking on it..
  4. Continue in this fashion until you navigate to your directory within the appropriate drop folder.
  5.  

Q: When I upload files to/download files from the CS111 server, files don't have the right name/format. What's the fix?

A: If your uploaded files end up having .bin or .hqx extensions, or if downloaded files don't have the right icons, your Fetch preferences are probably incorrect. You can fix them by installing the CS111 patches.


Symantec Cafe


Q: How do I tell if Symantec Cafe is installed on my Macintosh?

A: Follow the instructions for checking for Symantec Cafe that are on the CS111 Software Installation page.


Q: How do I install Symantec Cafe on my Macintosh?

A: Follow the instructions for installing Symantec Cafe that are on the CS111 Software Installation page.


Q: Symantec Cafe does not appear in the apple menu. How do I launch it?

A: First of all, the item that appears in the apple menu is labelled Symantec Project Manager, not Symantec Cafe. If this item is in the apple menu, select it.

If Symantec Project Manager does not appear in the apple menu, do not give up hope! It may just that no one has installed an alias to the Symantec Project Manager in the apple menu on your machine. You can instead launch the project manager by navigating through the following sequence of folders from your desktop:

  1. Macintosh HD (or whatever the hard drive folder is named on your computer)
  2. Key Servered Software
  3. Symantec Cafe 1.5

If there is no Symantec Cafe 1.5 folder, you're out of luck and must install Symantec Cafe from scratch. However, if there is such a folder, it should contain a file called Symantec Project Manager. Double-click on it to launch Symantec Cafe.

To avoid navigating to the Symantec Project Manager application every time you need to launch it, you can add an alias for the Symantec Project Manager to the apple menu. You can do this as follows:

  1. Navigate to the Symantec Project Manager as described above.
  2. Select the Symantec Project Manager by single-clicking on it. (Do not double-click on it, as that will launch it).
  3. In the File pull-down menu at the top of the screen, select Make Alias. This will create a Symantec Project Manager alias icon, which you should drag to an open space on the desktop.
  4. Navigate to the Apple Menu Items folder via the following sequence of folders: (1) Macintosh HD (2) System Folder (3) Apple Menu Items.
  5. Drag the Symantec Project Manager alias icon into the Apple Menu Items folder.
  6. Congratulations! You've just added a new item to the apple menu. From now on, you can just select the Symantec Project Manager alias item from the apple menu.
  7. You may also wish to add to the applet menu an alias for the Applet Viewer application (which is also in the Symantec Cafe 1.5 folder).


Q: Why doesn't CS111Applet appear as one of items in the Project Model menu within the new project dialog?

A: The Symantec Cafe 1.5 (Project Model) folder has not been properly initialized for CS111. You need to install the CS111 patch files on your machine.


Q: Why are question marks showing up in my project window?

A: Within a project window, a question mark indicates that the project manager doesn't know where to find the associated file name. Here are some typical reasons for this situation:


Q: What does an underlined entry within my project window mean?

A: It means that the file with the underlined name in a different directory from the project file.


Q: When I update a Symantec Cafe Project, the .class files don't show up in the right directory. Why?

A: It's likely that you're using a PC-formatted disk. Symantec Cafe 1.5 does not interact well with PC formatted disks. Your disk is PC-formatted if the disk icon says "PC". If you have a PC-formatted disk, you should copy its contents to a Mac-formatted disk, and should use only Mac-formatted disks for the rest of the semester!


Applets


Q: Why can't I get a remote applet to run in my home page?

A: There are numerous reasons why an applet might not run on your home page. Before you do anything else, read the applet invocation notes, and follow the steps explained there. If you still have problems, here are some possible reasons:


Q: I can get a remote applet to run, but the images don't appear. Why?

A: If the applet is running, then your <applet ..> tag codebase attribute is correct. But if images are not appearing, it means that the addresses for data resources are not correct. See the notes on referencing data resources at the end of the applet invocation notes for how to fix this.


Java Programming


Q: How do I change the background color of my applet?

A: Add the following method to your applet

	public void init() {
	  this.setBackground(bgcolor);
	}

where bgcolor is an expression denoting the background color you want. Important: do not use the method invocation this.setBackground(bgcolor); within an applet's paint method -- this will cause the applet to get stuck in flicker mode.


Q: My applet gets stuck in a flickering mode. What's wrong?

A: It's likely that you have a method invocation this.setBackground(bgcolor); within the applet's paint method. As noted in the answer to the previous question, this invocation should appear in the applet's init method, not its paint method.


Q: I invoked a graphics method to draw something on the screen,but it didn't appear in the window. Why?

A: Here are several possible causes for missing graphics:


Q: Where can I read about arithmetic in Java?

A: Here are several sources for details on Java arithmetic:


Q: What are floating-point numbers?

A: A floating-point number is a number that has a fractional part; it is written with a decimal point, e.g.: 2.5, 3.141, -5.99. Floating point numbers are distinguished from integers, which have no fractional part. In Java, there are two types of floating-point numbers, those of type float and those of type double. Numbers of type double have higher precision than those of type float. By default, we will use double for floating-point numbers in CS111.


Q: How can I convert between ints and doubles?

A: If exp is an expression denoting an int, it can be converted to a double by means of a so-called "cast" expression:

(double) exp

If exp is an expression denoting a double, it can be converted to an int by means of a "cast" expression that truncates the information after the decimal point:

(int) exp

Here are some examples:

Java Expression

Value

(double) 17

17.0

(int) 3.141

3

(int) 5.99

5

(int) -3.141

-3

(int) -5.99

-5

In practice, converting an int to a double is rarely needed, since most binary operators (e.g. +, -, * , /, <, >, ==, !=) automatically convert an int argument to a double when the other argument is a double. (But see the question about dividing two ints, below.) Here are some examples involving addition:

Java Expression

Value

10 + 3

13

10.9 + 3.141

14.041

10.9 + 3

13.9

10 + 3.141

14.141

((int) 10.9) + 3

13

(int) (10.9 + 3.141)

14.141

(int) 10.9 + 3.141

13.141

2.5 + 3.5

6.0

Note in the example

(int) 10.9 + 3.141

that (int) binds more strongly than +; that is, the above example is treated as:

((int) 10.9) + 3.141

Sometimes truncating the fractional portion of a double is not the desired behavior -- instead, we want to find the floor (round toward negative infinity), find the ceiling (round toward infinity), or round toward the nearest integer. These calculations are performed by the Math.floor, Math.ceil, and Math.round library functions, as shown below:

Java Expression

Value

Math.floor(3.141)

3

Math.ceil(3.141)

4

Math.round(3.141)

3

Math.floor(5.9)

5

Math.ceil(5.9)

6

Math.round(5.9)

6

Math.round(2.5)

3

Math.round(3.5)

4

Math.floor(-3.141)

-4

Math.ceil(-3.141)

-3

Math.round(-3.141)

-3

Math.floor(-5.9)

-6

Math.ceil(-5.9)

-5

Math.round(-5.9)

-6

Math.round(-2.5)

-2

Math.round(-3.5)

-3

See the java.lang.Math API for more information on library math functions.


Q: How can I get a double result from dividing two ints?

A: In Java, the division of two numbers of which at least one is a double always yields a double result. However, dividing two ints always yields an int -- this is the result of so-called "integer division", in which any fractional portion of the result is truncated. How can we get a double result from dividing two ints? By first casting one or both of the integer arguments to a double. Here are some examples:

Java Expression

Value

7 / 2

3

7.0 / 2

3.5

7 / 2.0

3.5

7.0 / 2.0

3.5

((double) 7) / 2

3.5

7 / ((double) 2)

3.5

(double) (7 / 2)

3

(double) 7 / 2

3.5

((int) 7.0) / 2

3