reset password
Author Message
Anonymous
Posts: 166
Posted 19:25 Jan 15, 2014 |

Two questions I have about the lab that is due tonight.

1. For the P2.3, basically what I am reading is that I should copy the testunion2 code, but just change the point where the two rectangle is not intersecting no more? Meaning the two rectangle meet wall to wall, but never intersecting.

Is this what you are asking for? Just asking to get some understanding of the question.

 _ _ _
|         |
|         |
|         |
|         |
|         |
|______|________
|                          |
|                          |
|                          |
|_______________|

 

2. For the Days project (P 2.6), basically we create objects in the "Days" class just like what the video did in the example Sally? How would you start writing the JUnit when the object cant be made into code? Would like some help.

Thank you. One confusing college student.

Last edited by Anonymous at 19:26 Jan 15, 2014.
rabbott
Posts: 1649
Posted 21:04 Jan 15, 2014 |

For problem P 2.6 create a DaysTest class and complete the following method in it.

    @Test 
    public void testLeapYear() {
        // Create a day for Feb 28, 2014
        Day dayIn2014 = new Day(2014, 2, 28);
        // Add one day to it

        dayIn2014.addDays(1);
        // Check to see if you get the right day. The right day should be March 1, 2014.

        assertEquals(2014, dayIn2014.getYear());
        assertEquals(3, dayIn2014.getMonth());
        assertEquals(1, dayIn2014.getDayOfMonth());

        // Do the same thing for  Feb 28, 2015,  Feb 28, 2016,  Feb 28, 2017
        // In one case (leap year), adding a day should produce Feb 29 instead of March 1.
        // Write the test to see if it does.
        Day dayIn2015 = new Day(2015, 2, 28);
          ...

        Day dayIn2016 = new Day(2016, 2, 28);
          ...

        Day dayIn2017 = new Day(2017, 2, 28);
          ...

}

        

Last edited by rabbott at 21:25 Jan 15, 2014.