o
main
.
Each lab from Lab 1 will be presented here as two exercises: the class itself, and then the app class containing main
(and possibly
supporting methods, such as my doIt
and printQuadrantInfo
in my lecture implementations(.
Color.java
from Lab 1 to Color.java
and ColorApp.java
for Lab 2.
main
and supporting methods (e.g., doIt
) should be deleted from the class and remains in the app class
main
value
variable from CounterApp
and add a corresponding instance variable to
Counter
up
in Counter
and add
from Container
from the app class,
make instance methods instance methods (by getting rid of statc
and fixing up the signatures — mainly removing argument/parameters)
toString
to each class; you can tell what the string representation should be by looking at the sample output.
Counter
) (Approval)main
method (that's the next exercise)
toString
method for the class should return the value of the class as a String (remember, you can convert non-String values to String by concatenating them with "", e.g., i+""
).
UpperBoundedCounterApp
) (Approval)main
method (and any other supporting methods you want) that illustrates the use of your class from Lab 2.1.1. The app should consume
the same input and produce the same output as in Lab 1.1.1.
BanAccount
example of Lecture 1 retained the main
method in the class itself, we are going to
start off right by removing it to its own app class.
Container
) (Approval)
The {}
's (as in the corresponding class
in Lecture 2).
ContainerApp
) (Approval)
CAPACITY
)
toString
find
to get
Color
)) (Approval)static
(and final
— use the proper naming convention of
all caps.
ColorApp
)) (Approval)r: 0 g: 0 b: 0 is valid: true hex: #000000 name: Black is grey: true is primary: false r: 0 g: 0 b: 255 is valid: true hex: #0000ff name: Blue is grey: false is primary: true r: 0 g: 255 b: 0 is valid: true hex: #00ff00 name: Green is grey: false is primary: true r: 0 g: 255 b: 255 is valid: true hex: #00ffff name: Aqua is grey: false is primary: false r: 255 g: 0 b: 0 is valid: true hex: #ff0000 name: Red is grey: false is primary: true r: 255 g: 0 b: 255 is valid: true hex: #ff00ff name: Magenta is grey: false is primary: false r: 255 g: 255 b: 0 is valid: true hex: #ffff00 name: Yellow is grey: false is primary: false r: 255 g: 255 b: 255 is valid: true hex: #ffffff name: White is grey: true is primary: false r: 10 g: 20 b: 30 is valid: true hex: #0a141e name: Unknown color (#0a141e) is grey: false is primary: false === Printing out the pre-defined Color objects BLACK: (0, 0, 0) WHITE: (255, 255, 255) RED: (255, 0, 0) GREEN: (0, 255, 0) BLUE: (0, 0, 255)
static
objects of the class within the class
Quadrilateral
) (Approval)
I've supplied the Line
and Point
classes (both as source and class files; you might want to experiment with your IDE in how to add .class
files
to your project.
Point
s
Line
s
Point
objects
Point
s.
Point
class … you have that from your instance variables
isRhombus
amd isParallelogram
methods require the length of the various sides, and length is a method of
the Line
class. You have a couple of options to get that from your four Point
instance variables:
side1
of type line
, side2
, etc (you can initialize them in the constructor
together with the four Point
instance variables
Line
objects) in the above two method (where you need them).
length
method on the sides under being looked at.
toString
requirement (it should probably be the concatenation of the toString
of the four Point
instance variables
QuadrilateralApp
) (Approval)
Line
s or Point
s
Phonebook
) (Approval)Phonebook
of Lab 1.5 as a class
toString
method should be analogous to that of the Phonebook
of Lecture 2, but with a first name added (see stdout output below)
lookup
and reverseLookup
return null
in the event of failure.
PhonebookEntry
class source file as well.
sort
method should sort the array only, not write it out to any file
PhonebookApp
) (Approval)PhonebookEntry
class source file as well the Phonebook
file).
stdout
{Arnow, David: 123-456-7890, Harrow, Keith: 234-567-8901, Jones, Jackie: 345-678-9012, Augenstein, Moshe: 456-789-0123, Sokol, Dina: 567-890-1234, Tenenbaum, Aaron: 678-901-2345, Weiss, Gerald: 789-012-3456, Cox, Jim: 890-123-4567, Langsam, Yedidyah: 901-234-5678, Thurm, Joseph: 012-345-6789} lookup, reverse-lookup, quit (l/r/q)? last name? first name? David Arnow's phone number is 123-456-7890 lookup, reverse-lookup, quit (l/r/q)? phone number (nnn-nnn-nnnn)? 456-789-0123 belongs to Augenstein, Moshe lookup, reverse-lookup, quit (l/r/q)? last name? first name? -- Name not found lookup, reverse-lookup, quit (l/r/q)? last name? first name? Gerald Weiss's phone number is 789-012-3456 lookup, reverse-lookup, quit (l/r/q)? phone number (nnn-nnn-nnnn)? -- Phone number not found lookup, reverse-lookup, quit (l/r/q)? 3 lookups performed 2 reverse lookups performed