Jan 11-Apr. 26, 2006, Wednesdays, 5:15-7:45 PM, Crawford Science Tower room 523. Final exam is Wed. May 3, 6:00-8:00 PM.
This course is a continuation of Data Structures and Programming (Java). Topics include graphical user interfaces (GUI), network programming, applets, and threads. You should already be familiar with Java programming including object-oriented techniques, exceptions, and basic data structures such as arrays, stacks, linked lists, and trees.
Matt Mahoney, email@example.com or firstname.lastname@example.org
Java, How to Program, Deitel & Deitel, 6th Ed. We will cover the remainder of the book not covered in CIS5100 (chapter 11 to the end). The book comes with a CD that you won't need.
Code examples from book
50% homework and 50% exams. Programming assignments will be submitted by email only. Submit only source code (.java) preferably as ONE file. There is a late penalty of 20% per day including non-class days, weekends and holidays.
There will be 4 exams including the final. Your lowest grade is dropped. The other 3 exams are weighted equally. There are no makeup exams for any reason. Exams are open book and open notes. Exams will usually be given in the first hour of class before break so that we can go over them afterwards.
Attendance is not mandatory. However you are responsible for (and will be tested on) all material covered in class.
Students are expected to do their own work (no group projects) and to cite all outside sources, including help received from other students. You are responsible for knowing the policy on academic honesty, covered in the student handbook, p. 33.
I normally answer email within 24 hours. In case of a conflict that cannot be resolved with me, resolution policy is covered in the student handbook, p. 55. The CIS program chair is Dr. Rhoda Baggs Koss, 321-223-4821, rkoss (at) fit.edu. Her office is on the 5th floor of the Crawford Science Tower.
Within 24 hours after the first class you should receive an email notifying you that you have been added to the fit-cis5100 mailing list. If you do not, then email me to request an invitation. You are responsible for all material posted to the list, such as homework assignments, test announcements, and additional course material. Once you are a member, you are encouraged to post questions (or answers) to the class at email@example.com. If you have a Google account you may also access the list at the members-only website groups.google.com/group/fit-cis5100.
If you took CIS5100 from me last semester and still have the same email address then you are already subscribed and don't need to do anything.
The computer should play intelligently. If the computer can win or block you from winning on the next move then it should do so. For example, it should place an X in the left side of the middle row below.
X | O | ---+---+--- | O | ---+---+--- X | | O
For this program, use graphics to draw the grid in black on a white background, the O's in blue and the X's in red. If the user resizes the window, the drawing should be scaled or stretched to fit (so that the O's might be drawn as ovals). Give the user a means to change the color of the O's and X's (e.g. a JColorChooser) at any time during the game. Add a JSlider to allow the user to change the line thickness of the grid, O's and X's at any time during the game. Set the initial line thickness to 4 pixels.
Your game might work like the applet below, although it does not have to follow this user interface exactly. (You need Java 5 to view this applet). Note that an applet can't exit or be resized like your program.
This applet simulates planets in space following Newton's law of gravity. To create a planet, left click in the black area. The size of the planet will depend on how long you hold down the mouse button. You can "throw" a planet by moving the mouse as you click. The initial velocity will equal that of the mouse.
The display is centered over a "home planet", which appears fixed in the center of the screen, although (like the Earth) it is actually moving. You can change the home planet by right clicking on another planet.
The "Zoom In" and "Zoom Out" magnify the display by 2 and 1/2 respectively. The "Clear" button removes all the planets and resets the zoom level.
The planets obey Newton's laws of physics in two dimensions. Each planet has a position (x,y), a velocity (dx,dy), and a mass (m). Each planet exerts a gravitational force on all the other planets: f = Gm1m2/r2, where m1 and m2 are the masses of the two planets, r is the distance between them, and G is a gravitaional constant. (You can use G = 1 or whatever value makes the animation look right).
Note that force is a vector (fx,fy) in the direction of the other planet. It can be computed: fx = Gm1m2rx/r3 where rx is the x component of the distance. fy is similar. These forces are summed over all the other planets.
At each time step the position and velocity of each planet is updated as follows:
dx = dx + fx/m dy = dy + fy/m x = x + dx y = y + dyThe time step in this animation is 30 ms. This is just fast enough that the motion appears smooth.
Planets will collide if they touch, forming a new planet whose mass is the total of both planets. The collision preserves momentum, e.g.
dx = (m1dx1 + m2dy2) / (m1 + m2) dy = (m1dy1 + m2dy2) / (m1 + m2)
All planets have area proportional to their mass (since there are 2 dimensions). The mass in this applet is 0.5 + the number of time steps that the mouse button is held down. I used a radius of 40*sqrt(m).
The applet allows up to 10,000 planets, although it is not likely you could create that many and have the animation run smoothly. I tested it on a 2.2 GHz Athlon and it will run smoothly with 1000 planets before saturating the CPU. Note that the time complexity is O(n2) to compute the forces on n planets.
For this program, you can use any color scheme you want. (It does not have to copy the above applet exactly). Also, you don't have to duplicate the feature of changing home planet with a right mouse click. However, all other features should be implemented.
Submit one file, Orbit.java, by email, and no other files. This should be an applet, not an application. I will test it in appletviewer and/or a web browser with my own HTML file:
<html><applet code=Orbit.class width=600 height=500></applet></html>Be sure your program is documented and readable. I am interested in commenting the program requirements and overall structure, the "big picture", not line by line commments.
Note: there will not be any more programming assignments. The first 6 assignments sum to 80 points, so everyone will be given 20 free points to bring the sum to 100. This is 50% of your grade. The other 50% is the average of your best 3 exams. If this exam is too hard, you may drop it and take the in-class final exam instead. Otherwise the final is optional.