Instructions: Answer as many of the following questions as you can during the lab period. If you are unable to complete the assignment during the lab period it is strongly recommended that you complete it on your own.
Getting Ready: Before going any further, you should:
Constants
, SemesterUtiltities
, and
Example1.java
in the editor.
Constants
, SemesterUtiltities
, and
Example1.java
.
Example1
.
FALL
to TALL
in
Constants.java
.
Constants.java
.
Example1
.
Example1
executed
given that it uses Constants.FALL
which is no
longer defined. Why did it execute? (You may not know the answer
to this question but you should be able to make some conjectures.)
Example1.java
.
TALL
back to FALL
in
Constants.java
.
SUMMER
to
Constants.java
and assign it the value 2.
Constants.java
and Example1.java
(remembering that it is very important to compile
Example1.java
even though it did not change).
Example1
.
SUMMER
and
FALL
in the proper order (in Constants.java
)
and adjust their values accordingly.
Constants.java
and Example1.java
.
Example1
.
System.out.println(SemesterUtilities.startingMonth(7));
to the main()
method in Example1.java
.
Example1.java
compile?
System.out.println(Constants.SPRING);
String
contants rather than an actual enumerated type.
This part of the lab will help
you see some of the additional problems with this approach.
Example2.java
in the editor.
Example2.java
.
String.compareTo(java.lang.String)
can be used to compare two String
objects.
Use this method to assign second
to better
if second.compareTo(first)
is greater than 0
and to assign first
to better
otherwise.
main()
method
in Example2.java
.
System.out.println("Better grade: "+better);
to the end of the main()
method in Example2.java
.
Example2.java
.
Example3.java
in the editor.
Example3.java
.
compareTo()
method?
.class
files were created when you compiled
Example3.java
? (Hint: Look for all files that
start with "Example3" and end with ".class".)
public enum LetterGrade { F, D, DPLUS, CMINUS, C, CPLUS, BMINUS, B, BPLUS, AMINUS, A; }
from Example3.java
and into a file named
LetterGrade.java
.
.class
files in the directory
you created for this lab.
LetterGrade.java
and Example3.java
.
.class
files were generated?
Example3.java
.
LetterGrade.java
to support this new policy?
Sessions.java
that includes a Spring, Summer, and Fall semester (in the appropriate
order for a calendar year).
SemesterUtilities.java
and Example1.java
so that they work correctly with this enumerated type. (Hint: Think about
using a "for each" loop.)
Copyright 2010