CSSE 220 -- Object-oriented Software Development

Homework 6 Due at 8:05 AM on Day 7.

  1. Complete the assigned reading for the next session (see the course schedule). If there is something you do not understand, make note of it so you can ask about it.
  2. Begin to look at the Key Concepts from the end of chapter 4.  This is a good place to quickly notice things you might have missed from the chapters. At some point (probably after break) we will have a "Key concepts quiz" over chapters 1-4.
  3. Complete the Angel quiz over the previous reading (4.2-4.4). You'll find this on the course Angel page, under Lessons → Assignments → Reading Quizzes → Quiz 5.
  4. Do the written exercises that are listed below.  You may write them neatly by hand or do them on your computer and print them. Turn in hard copy at the beginning of the Day 7 session. Include your name and section number at the top of your paper. 
  5. Finish the Unit Testing Exercise from class. The goal is to have a completely working PigLatiner.transform method (I.e., it does the right thing for any argument that we can pass to it), and a collection of JUnit tests that assure us that this is really the case. When you have completed this, share your project to your SVN repository using Team > Share.
  6. Finish the code for your BigRational class. You should also try to complete the Unit Tests so you do not have too much to do after Tuesday's class, but it is okay if you do not finish the unit tests until Day 8 at 8:05.

Written problems

  1. (5 points)  Weiss exercise 2.11.
  2. (5 points)  Weiss exercise 2.12.  You do not have to do this on your computer, but you are welcome to do so if you wish, and paste the code into your document (or just print it if you did the rest of the problems by hand).  You should not use high-level tools like StringTokenizer to do this, but should use the basic String operations (indexOf and substring may be particularly helpful).  The following code and output may help clarify what the method is supposed to do.

    public static void main(String[] args) {
        String[] stringList = split("Here is a short sentence.", " ");
        for (String s : stringList)
           System.
    out.println(s);
        System.
    out.println("-------");
        stringList = split("abracadabra.", "bc");

        for
    (String s : stringList)
           System.
    out.println(s);
    }

    Here
    is
    a
    short
    sentence.
    -------
    abracadabra.
    
  3. (3 points)  Weiss exercise 3.11.  Read the first sentence as " ... a single private constructor and no other constructors."
  4. (2 points) Weiss exercise 3.12.
  5. (8 points) List the number of each of the statements in the main( ) method of the following program, that would have to be commented out in order to make this code compile and run.  For each statement that you list, explain why it is illegal.
       public class HW6StaticMethods {
      
       public int pi;
       public static int psi = 5;
       
       public static int triple(int i) {
          return 3*i;
       }
       
       public int quadruple(int i) {
          return 4*pi;
       }
       
       public HW6StaticMethods(int i){
          this.pi = i;
       }
       
       public static void main(String[] args){
          
          HW6StaticMethods hw6 = new HW6StaticMethods(12);
          /*1*/ System.out.println(pi);
          /*2*/ System.out.println(psi);
          /*3*/ System.out.println(quadruple(6));
          /*4*/ System.out.println(triple(7));
          /*5*/ System.out.println(hw6.pi);
          /*6*/ System.out.println(hw6.psi);
          /*7*/ System.out.println(hw6.quadruple(6));
          /*8*/ System.out.println(hw6.triple(7));
       }    
    }