Last modified 3 years ago Last modified on 2015-03-04 08:19:43

Demot » Demo 8, 9.3.2015

Points 2x

From here starts a new demo partition and the maximum amount of points will be 8 (more demoes will be translated based on needs but currently there might be less than 8 worth of points). The demo points from 8-12 will be count as double in the formula for courses grade:

3/5*test + demo points from period 1 + 2*demo points from period 2

When submitting demo tasks, simply put normal amounts of demo points, the increase in points is calculated automatically by the demo system.

Remember to test all the tasks that are somehow possible to be tested! You can only mark 0.5 points for a task without tests that contains functions.

Task 1-2*. Ski jumping

Take the answer from last times demo task 7.7-8 from and turn it into real object oriented programming, so that the next kind of mainProgram will work. You can translate methods on your own will.

The example is quite huge so I will add translations of the finnish words in [] like kissa[cat]

  public void kisa[race]() { 
    Kilpailija[Participant] toni = new Kilpailija("Toni",3); 
    Kilpailija matti = new Kilpailija("Matti",7); 

    toni.setPituus[setLength](1,107);       // 1. round, 107 m
    toni.setPituus(2,100);                  // 2. round, 100 m
    toni.setTuomari[setJudge](2,1,19.0);   // 2. round, 1. judge, 19 p 
    toni.setTuomari(2,2,18.0);            // 2. round, 2. judge, 18 p




  public static void main(String[] args)  { 
    Makihyppy[SkiJump] kisa = new Makihyppy(); 

The idea behind the code is that there are judges and lengths of jumps and all have to be accessed through their capsulating class instead of calling them directly. It is highly recommended to go to computer class to have help with this task if there's any problems with translations or getting the idea of the task.

Task 3*. Postal fee with object array

Check the answer for demo 7 task 4 Change the answer so that you will use an object array of class PriceAndWeight(with attributes price and weight) instead of 2 different arrays. Also write function double postingFee(int weight).

After that is done, make a new solution using 2-dimensional array that has weight in its first line and in second line the price.

Task 6*. Largest of a matrix

Write function largestOfMatrix that returns the largest item in a 2 dimensional array.

Task 7. Sum of matrix using the sum of an array

Take the answer to demo 7 to the limits of an array task. Using the sum of that task, implement sum function that can be used with 2 dimensional array. (Don't copy, call the sum-function)

Task 8. Date

Find out how you can check the date using Javas libraries. Write methods dateToday that will find out the current date and that implementation the your own Date-class from earlier demo sessions. Also change the constructor method so that if no parameters are given or some of the info is not complete, the constructor will call the dateToday -method to find out the current date.

For example:

  Date janu2005 = new Date(1,1,2005)=>  1.1.2005 
  Date january2014 = new Date(1,1); // =>  1.1.2014
  Date march2014 = new Date(1);  // =>  1.3.2014 
  Date today = new Date();       // =>  5.3.2014
                                  // (tested 5.3.2014)