Studio 7 Design Problems
- A number of stories appear below about various object types.
- Pick an object type, read the story, and design and implement
a class in your workspace for the object type.
- Include Javadoc comments in your code, and if possible, generate
the Javadoc using eclipse.
From the Project menu choose Generate Javadoc.
- Write a simple test or two to test your implementation.
- Repeat this process with another object type until the TA comes to you
with a modification
for one of the classes you have implemented.
Be sure to commit your work!
- A rectangle has a length and a width. A rectangle should be able
to provide its area and perimeter. A rectangle can indicate whether it
is smaller than another rectangle in terms of area. A rectnagle can
indicate whether it is in fact a square.
- When a Die is constructed, it is specified to have
n number of sides. Each time the die is thrown,
a random integer is returned in the range 1..n, inclusively.
- A fraction has a numerator and denominator. A faction should be
able to add itself to another fraction, returning a new fraction that
represents the sum. A fraction should be able to multiply itself
by another fraction, returning a new fraction as the product.
A fraction should be able to take the reciprocal of itself, returning
that value as a new fraction.
A fraction should be able to simplify itself, returning a new fraction
as that simplification.
This is a good one to do if you are thinking of undertaking the
Julia set extension. Find somebody who knows about complex numbers if
you are not solid with them.
- A complex number has a real and imaginary part, each represented as a double.
A complex should be able to add itself to another complex number, returning
a new compmlex number as the sum (see below). Similarly, a complex
number should be able to multiply
itself by another complex number, returning a new complex number as
- A complex number with real part a and imaginary part b is usually
shown as a + bi.
The result of adding two complex numbers a and b is another complex number whose
real part is the sum of
the real parts of a and b
and whose imaginary part is
the sum of
the imaginary parts of a and b.
- The product of (a+bi) and (c+di) is (ac-bd) + (ad+bc)i
A hockey player has a name and a jersey number. Most players shoot either
right or left, but some can shoot either way. A player can be right- or
left-handed, but shoot either right or left. This object should be
able to react when a player completes a game, recording how many goals
and assists the player earned in that game. A player has a certain
number of goals and assists he or she has recorded over all games
played. Also, a player
has a certain number of points, which is the sum of the goals
and assists a player has earned. A player has a certain number of games
he or she has played.
- A university course has a number, like 131, and a department, like CSE.
Each course has a certain number of students currently enrolled. It is
possible for students to add or drop the course after the course has
been constructed. It should be possible to determine the number of
students who are currently enrolled in a course.