Graphic by Keith Ohlfs |
Questions (FAQ) |
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.
The following questions are linked to answers below.
The CS111 server
A: There are many possible mistakes you may be making. Here are some important tips to follow:
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:
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.
A: Follow the instructions for checking for Symantec Cafe that are on the CS111 Software Installation page.
A: Follow the instructions for installing Symantec Cafe that are on the CS111 Software Installation page.
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:
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:
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.
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:
A: It means that the file with the underlined name in a different directory from the project file.
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!
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:
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.
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.
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.
A: Here are several possible causes for missing graphics:
A: Here are several sources for details on Java arithmetic:
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.
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:
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
See the java.lang.Math API for more information on library math functions.
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:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|