In this course you will be completing your homework with a programming partner. If you previously have taken CS1101 or CS1102, then you know how this model works. Students will work in the same pairs throughout the entire term. At the start of the term you may request to form a pair; we will pair up students who do not express preferences.
By structuring homeworks around teams, we hope to improve both the quality of the assignments as well as individual student learning. Programmers must learn how to work in teams and this is an opportunity to hone your teamwork skills.
You will need to send preferences for your homework partner (if you have any) to us. Send one email to the <csonger@wpi.edu> with both names (CCed to your partner); mention CS2102 in the subject line. Anyone who has not selected a homework partner by 5 PM Thursday October 26th will be assigned one. We will assign teams of two unless we end up with an odd number of students in the class. You may request a trio, but tell us who will work with someone else if we need to split off one person.If you want us to assign you a partner, but do not want to be paired with a particular student (or two), in the above email include the name of the person you do NOT want to be paired with. Please make it clear in your message that you are asking to not be paired with the named student(s) in this case!
The final student pair programming teams will be announced in class on Friday October 27th.
As you design more complex programs, it is imperative that you show you have tested the programs under numerous circumstances. A Test Case shows the execution of a program and compares expected output against actual program output. There are two cases to consider:
import java.util.Scanner; /** * Program to determine if a number is even or odd. * * @author George Heineman (heineman@cs.wpi.edu) * * Test Cases: * 1. 5 outputs "5 is odd" * 2. '4' outputs "4 is even" * 3. 'a' outputs an EXCEPTION */ public class SampleTestCaseWithInput { /** * @param args */ public static void main(String[] args) { // request input from user Scanner s = new Scanner (System.in); System.out.println ("Enter a number and I will tell you if it is even"); int n = s.nextInt(); // determine even or odd if (n % 2 == 0) { System.out.println (n + " is even."); } else { System.out.println (n + " is odd"); } } } |
Throughout the course, I document each code example using a standard that I have introduced informally. Here is a formal declaration of what I am expecting:
Documentation for each Program | At the top of the program file, include a comment
explaining purpose of program and the author of the program
/** * Compute Area of Ring. * * @author George Heineman (heineman@cs.wpi.edu) */ public class ClassName { |
Documentation for each Method |
/** * Return TRUE if the digit is in the range '0' .. '9'; FALSE otherwise */ static boolean validDigit (char d) { ..... } |
Documentation internal to each Method |
public void someMethod () { ... // Create space for an array of three ints. Initial // values are all.... ? int [] ivals = new int[3]; // access information from keyboard. Scanner s = new Scanner (System.in); ... } |
i++; // increment i by 1
Better to say (as we have shown with the while loop) a comment like i++; // Advance loop