Mandatory assignment #1
Without using floating point:
- Extend the solution from step 1, 2, and 3 of last weeks
exercises with a user interface that includes a zoom-function that
makes it possible to show only a part of the graph. As a minimum
your solution must be able to display a subarray between two indices
xmin and xmax of y i.e. the y-values in y[xmin..xmax].
- Extend your solution with an input method that can read the
values of y from an external file. Hint: use the skeleton of the Java method presented in the
lecture on February 22. Here are two files that you must be able to
read in and display: test1 and test2.
You do not have to use the methods shown for exercises 1-3 pertaining
to Lecture 3. The idea is that you should have a class implementing
Canvas and use paint(Graphics) to draw on it. One way to do it is to
have one method drawing on the canvas and another method making the
graph to be drawn from the supplied array y.
The assignment is due on March 1 at 12:00. Send it to Ebbe Elsborg
by email in a sensible format. You can consider the assignment handed
in when you receive a confirmation mail from Ebbe.
Mandatory assignment #2
-
Consider the following problem:
"Given 3 arguments x, y and z return the middle one"
Define a structural test for each of the two implementations below as well as a functional test.
- The first implementation consists of one function:
public int middle(int x, int y, int z)
{
   if( x < y && x < z )
   {
     if( y < z ) return y;
     return z;
   }
   if( y < x && z < x )
   {
     if( y < z ) return z;
     return y;
   }
   return x;
}
- The second implementation consists of two functions:
public int least(int a, int b)
{
   if( a < b ) return a;
   return b;
}
public int middle(int x, int y, int z)
{
   m = least(y,z);
   if( x < m ) return m;
   m = least(x,z);
   if( y < m ) return m;
   return least(x,y);
}
-
Select a part of your previously handed in assignment and J2MEUnit
test it. Try to select an isolated functionality; if your program does
everything in one method, you are allowed to move a piece of
functionality to a separate method in order to test it.
Do not test to much. Complete testing is an infinite amount of work. Your goal
is to demonstrate that you can implement into the J2MEUnit framework,
and do a reasonable test. You should be able to accomplish that
with around 5 assertions.
Feed back on the assignment will be sent to you via email by the
teaching assistant or teacher that has corrected it at April 19 the
latest. If you do not get the assignment approved, you have one week
to resubmit.
Mandatory assignment #3
Implement a 3D 2-player version of PONG. You are allowed to use the code from the lectures as well as any code you have produced during the exercises.
The rules are written down below for reference.
Your application must be able to establish a connection to another phone and initiate a game upon acceptance from both phone-holders. It must detect the end of the game and display on each phone wether the phone-holder has won or lost the game.
During the game each players points must be displayed.
The assignment is due on April 20 at 12:00. Send it to
Rasmus Lerchedahl Petersen
by email as a zip'ed WTK project. You can consider the assignment handed
in when you receive a confirmation mail from Rasmus.
Feed back on the assignment will be sent to you via email by the
teaching assistant or teacher that has corrected it.
Rules of PONG
-
The game board consists of a rectangle with walls on two opposing edges.
On the two edges without walls are placed two pads. Each pad is a movable piece of wall that is shorter than the edge.
- There are 2 players
-
Each player control a pad. A player can move the controlled pad along the edge.
-
A ball is bouncing between the walls and pads. If the ball gets behind a pad the player controlling the other pad is awarded a point.
-
At the beginning of the game and after a player has scored a point,
the ball starts in the middle of the game board with a random direction.
-
The game is over when one player obtains 10 points. That player has won the game. The other player has lost.
Hints
- If you use the code from the lectures the game board is draw for you. If you find the rotation irritating it should be easy to get rid of.
-
If you look at the code to "The Game of Life" that comes with the WTK (Demos3D) you can see how to draw a string to the screen with updated information.
-
As in the 2D bouncing ball exercise, let one phone do collision detection, ball movement, counting of points and detection of game over, and let the other phone act merely as a display and input device.
Possible extensions (NOT mandatory, sheer fun and show-off)
- Make the pads different colors.
- Make the ball look more like a ball (for instance by rotating it).
- Take advantage of the 3 dimensions and let the ball bounce inside a tunnel.
Pads might then be rectangles.
|