From leavens@cs.iastate.edu Tue Sep 9 08:19:40 2003 Date: Tue, 9 Sep 2003 08:19:16 -0500 (CDT) From: Gary T. Leavens To: cs362s@cs.iastate.edu Subject: Re: Com S 362 feedback: Homework Feedback Hi, On Tue, 9 Sep 2003, WorldWideWeb wrote: > Currently the am(hour,minutes) and pm(hour,minutes) methods in > TimeOfDay.java expect 0<=hour<=11 . > Shouldn't they accept pm(12,30) to represent 12:30pm? Since the > method as I understand it is to convert to a "military" time it > should never expect a 0 for hour instead 1<=hours<=12. No, the way they are designed, 12:30pm is pm(0,30). The design may be idiosyncratic, but it seems to be self-consistent. -- Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 -------------------------------------------------------- From leavens@cs.iastate.edu Wed Sep 10 14:26:58 2003 Date: Wed, 10 Sep 2003 14:26:43 -0500 (CDT) From: Gary T. Leavens To: crazyabe@iastate.edu Cc: Staff for Com S 362 Subject: Re: cs362: about JUnit Hi, On Wed, 10 Sep 2003 crazyabe@iastate.edu wrote: > hi, I have a question about how to use Junit. > I looked through eclipse folder to > find the the jar file that you used to lecture today, > but I couln't find it. > Do I have to download it separately? > or is it already included in eclipse? I download this separately myself, and used the jar file from outside of Eclipse that I downloaded. This has the advantage that you get the sources and documentation for JUnit with it. You can get from junit.org. However, the JUnit jar file (without the sources) also is part of Eclipse, and you can find it in the eclipse/plugins/org.junit_3.8.1 directory. The disadvantage of this is that you don't get the javadocs with it, and so you won't have as much help from within Eclipse if you do things this way. -- Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 ----------------------------------------------------------------------------- From leavens@cs.iastate.edu Sat Sep 13 16:20:58 2003 Date: Sat, 13 Sep 2003 16:16:22 -0500 (CDT) From: Gary T. Leavens To: Adam Nelson Cc: Staff for Com S 362 Subject: Re: HW 2 question Hi Adam, On Sat, 13 Sep 2003, Adam Nelson wrote: > The JUnit testing files say they have many problems, mainly complaining about > the assertEquals lines. I presume you mean the compiler or Eclipse complains about these lines before you run the program? > They seem to be a result of it not being able to find TestCase. It is also > commenting that import junit can't be resolved. This is a CLASSPATH problem. If you're in Eclipse, you need to add Eclipse to the Java Build Path as I showed in class on Wednesday, or as described in Exercise 1. In Java command line tools, make sure your CLASSPATH includes JUnit. See the running java page from the course web page. -- Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 --------------------------------------------- From leavens@cs.iastate.edu Sat Sep 13 16:26:22 2003 Date: Sat, 13 Sep 2003 16:25:59 -0500 (CDT) From: Gary T. Leavens To: Sayan Ranu Cc: Staff for Com S 362 Subject: Re: COMS 362: Correction to the TestCalc class from today's lecture; schedule Hi Sayan, On Sun, 14 Sep 2003, Sayan Ranu wrote: > I am a bit confused about the Appointment class in homework 2.In the > constructor nothing has been said about whether we should initilize the ending > time of the appointment.Should i initialize it? Otherwise I think it's giving > rise to a bit of confusion in some of the other functions. For Example in the > setLength() method and setStart method(), we don't know whether the ending > time is still or pointing to NULL.We need to modify it in these fucntions so I > feel it's very important to know that. Thank you. Yes, I agree it's very important. The javadoc comment and the JML specification for appointment both say that the appointment is for 60 minutes. Since it starts at 8AM, it must end at 9AM. This is just simple mathematics. If you have an appointment that starts at 10 and lasts for 20 minutes that tells you the ending time. If you have an appointment that starts at 10 and ends at 10:20, that tells you the length. The two are linked like that. Does that help? -- Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 ---------------------------------------------- From leavens@cs.iastate.edu Sun Sep 14 14:46:43 2003 Date: Sun, 14 Sep 2003 14:46:14 -0500 (CDT) From: Gary T. Leavens To: Jeff Groves Cc: Staff for Com S 362 Subject: Re: COMS 362: errors in the JUnit test classes? Hi Jeff, On Sun, 14 Sep 2003, Jeff Groves wrote: > By the way, were we supposed to make any changes to the AppointmentTest & > TimeOfDayTest classes given in Homework 2? When they're brought up in Eclipse, > there's errors everywhere. Or is the problem in not assigning a certain build > path? Yes, if you're getting errors in the testing classes, it's because you do not have the JUnit jar file in your Java build path in Eclipse. You need to change that for the project. If you need to, download JUnit 3.8.1 to get the jar file for JUnit. (It's already on the department machines, but if you're working from home, you will need to do this.) > Hopefully I can wait an hour or two after class to sort this out, test it, and > hand it in, unless you check the mail on Sundays. There's a late penalty if you hand it in after the start of class on Monday... -- Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 --------------------------------------------------------- From bgraves@cs.iastate.edu Sun Sep 14 17:51:47 2003 Date: Sun, 14 Sep 2003 17:06:23 -0500 From: Brett Graves To: mring@theringworx.com, cs362s@cs.iastate.edu Cc: leavens@cs.iastate.edu Subject: RE: cs362 [hw2] Null Objects Even though the subject says hw3, I assume you are talking about homework 2.  If so, then no, it doesn't automatically throw an exception if the object is not an instance of TimeOfDay.  Both methods getting called take Object o as the parameter, which accepts any object.  I think there may be some confusion since there are 2 compareTo methods, but if you notice in TimeOfDayTest line 254 casts null as an Object, so java knows to use the method that takes an object as the parameter.  You have to explicitly check whether that object is a TimeOfDay and if it is not, then you throw a ClassCastException in the case of the compareTo() method (as per the javadoc comments), or you just return false in the case of the equals() method, since it is clearly not equal to your TimeOfDay object if it isn't even in the same class. Hope this helps, if not feel free to send more questions.    Brett Graves -----Original Message----- From: mring@theringworx.com [mailto:mring@theringworx.com] Sent: Sunday, September 14, 2003 4:50 PM To: cs362s@cs.iastate.edu Cc: leavens@cs.iastate.edu Subject: cs362 hw3 Null Objects     I'm running JUnit to test my TimeOfDay class, and it is giving me two errors, which I believe are saying the same thing; one is for the compareTo method and the other for the eqauls method.     The JUnit errors out when I come across the NULL object in the test code (lines 238 & 254 of TimeOfDayTest.java). I thought the class automatically called an exception if the object was not an instance of TimeOfDay. I also used the Try...Catch code in my own methods to see if I could fix it that way, but it still gave the same error.     I've looked through this and previous semester's Q & A and haven't found anything that specifically resolves this problem. Any suggestions would be helpful.   Thanks.   Matthew Ring mring@theringworx.com ------------------------------------------- From leavens@cs.iastate.edu Sun Sep 14 21:17:05 2003 Date: Sun, 14 Sep 2003 21:13:26 -0500 (CDT) From: Gary T. Leavens To: Jeff Groves Cc: Staff for Com S 362 Subject: Re: COMS 362: errors in the JUnit test classes? Hi Jeff, The JUnit files are in /opt/junit/ on the department machines. I showed how to add a jar file to Eclipse's build path in class and it's also detailed in the Runnng Java web page for the course. See: http://www.cs.iastate.edu/~leavens/ComS362/running_java.shtml#EclipseAndJUnit for the details. Does that help? On Sun, 14 Sep 2003, Jeff Groves wrote: > I'm using the department machines. However, I don't know how to add it to the > Build Path. I don't think I can find it, or figure out how to get the program to > add it. What's really confusing is that there's also options to make JUnit classes. > > > Yes, if you're getting errors in the testing classes, it's because you > > do not have the JUnit jar file in your Java build path in Eclipse. > > You need to change that for the project. If you need to, download > > JUnit 3.8.1 to get the jar file for JUnit. (It's already on the > > department machines, but if you're working from home, you will need to > > do this.) -- Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 ---------------------------------------------------------- From leavens@cs.iastate.edu Sun Sep 14 22:34:12 2003 Date: Sun, 14 Sep 2003 22:29:40 -0500 (CDT) From: Gary T. Leavens To: Jeff Groves Cc: Staff for Com S 362 Subject: Re: COMS 362: errors in the JUnit test classes? Hi Jeff, On Sun, 14 Sep 2003, Jeff Groves wrote: > Okay, it's fixed now. For some reason, on Windows XP the ".jar" wasn't on the > junit, which probably was why I wasn't finding it. That is due to Microsoft, which thinks it is best to hide file name extensions from you by default. You can change that in XP (by opening the windows explorer on a directory, then click on Tools, then Folder Options, then scroll down and uncheck the box marked "hide extensions of known file types". I do this, which is why it looked different on my machine than yours. Sorry for the confusion. -- Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 ------------------------------------------