Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
CIT 591 Assignment CIT 591 Assignment 1: Multiplication Table Fall 2004, David Matuszek Purposes of this assignment: To get you started writing Java programs. To give you some exercise with loops and arithmetic. To introduce some of the ideas of pair programming. General idea of the assignment: Create and display, in a JApplet, a multiplication table for the numbers 1 through 10. Your running JApplet should look something like this. Details: Your applet should look more or less like the above, but it doesn't have to look exactly the same--it just has to be fairly neat. You will find that there is a lot of arithmetic involved in creating this applet--not in doing the multiplications (that part is trivial), but in figuring out exactly where to put the lines and the numbers. You and your partner will have to agree on things like how far apart the lines are. Hint: You can turn a number into a String by concatenating it with the empty string (n + ""). Experiment a bit with color. In the example, I drew all the square numbers in red. Here is a simple JApplet to get you started: import javax.swing.JApplet; import java.awt.*; public class Drawing extends JApplet { public void paint(Graphics g) { paintFirst(g); paintSecond(g); } private void paintFirst(Graphics g) { g.setColor(Color.BLUE); g.fillRect(20, 20, 50, 30); } private void paintSecond(Graphics g) { g.setColor(Color.RED); g.fillRect(50, 30, 50, 30); } } This program is to be written with a partner, if at all possible. There are various tasks to be done; here is one possible division of labor: One of you draws the lines. The other of you draws the products (the numbers inside the square). Either of you draws the row and column headers (numbers outside the square). Each of you draws your own name underneath the table. You don't have to do it exactly this way, as long as you and your partner agree, and each of you does part of the work. If you use the above starter code, one person could replace the code in the paintFirst method, and the other replace the code in the paintSecond method. Alternatively, you might decide to put all your code into the paint method. Do draw all lines and all numbers in loops. You should not have a long list of similar commands, one for each line or each number. Display your names underneath the table. If there is a clear division of who did what, you can indicate that fact there, but you don't have to. Restrictions: The more Java you know, the better. I am not one of those instructors that insist you can't use something until I've covered it in class! However...there are two caveats: Please make sure that your partner understands your code. If you want to use a Java feature that your partner doesn't understand, explain it to him/her. Conversely, if you don't understand a Java feature that your partner uses, ask about it. The new features of Java 1.5 are not covered in either textbook or in my lectures, and Java 1.5 is not installed in the labs. If you learn about these new features, don't use them...yet. It will just make trouble for everybody. (We will use Java 1.5 in CIT594, though). Grading: Grading on all programs is out of 100%. Programs with syntax errors automatically get zero. Some grading factors are subjective, such as whether your multiplication table is neatly drawn, and whether your code uses good indentation and variable names. You and your partner will each receive the same grade on this assignment, no matter how you split up the work. For various reasons, you don't generally get to pick your partner. I assign partners. I try to ensure that you work with a different partner each week. Due date: Thursday, Sept. 16, before midnight. Turn in your zipped assignment via Blackboard -- see Instructions for Using Zip Files and Blackboard for instructions. Your program should be ready to run under BlueJ, so include the files that BlueJ generates, along with your .java and .class files. Be sure to Submit File, not Add File! Programs submitted any other way will not be accepted. Just turn in one program for the two of you, please; whoever turns it in, please put your partner's name in the Blackboard comments field. Advice: Do not turn in a program with any untested changes, even if you (think you) only changed something in a comment. If you make any last-minute changes, test them before you submit the program. If a program doesn't work at all, don't turn it in. You'll just get a zero anyway, and you'll be wasting our time. Fix it and turn it in late. If you decide, after you have turned in a program, that you need to make changes and turn in a corrected version, it's OK to do so--just don't do this too often, because grading programs can be a lot of work. Of course, re-submitted programs after the due date will get late points taken off.