Last modified 3 years ago Last modified on 2015-09-15 13:26:06

Demot » Demo 3, 27.1.2014

Task 1. Algoritmh: Wildchar ?

Write an algorithm that will check if the given strings are the same as a string with the wildchars. (? can be used to equal any other character). Example:

 jono        maski
"Cat"       "C?t"      => same
"Doge"      "Do?"      => not the same
"Dog"       "Dig"      => not the same

TDD: make more test cases.

Task 2. Java: WildChar? ?

Make algorithm described in the first task into java language. Create tests and a main for the algorithm. You can make the tests using ComTestiä or with JUnittia. Example:

Example body for function:
public static boolean areSameWithWildChar(String message, String wildCharsIncluded){

Function can be used with:
  if ( areSameWithWildChar("Kissa","K?ss?") ) ...

Task 4*. Date-object

Create a class for storing date. Implement atleast a constructor and the method toString to transform the date-object into a String. Tests in some form or another. You can take hints from:

You can use the main from lectures:

Task 5*. Room metrics

Design and create a java program that has a dialog for inputting metrics from a room. The program will then calculate the area and volume of the room and show it.

You can take examples from

Task 6*. Making similar code into 1 method

In the task in demo 2 there are two similar methods. Turn these methods into one method vaihdaAlkuLoppu (that takes an approppriate amount of parameters) and then make parametrised calls to the vaihdaAlkuLoppu-method from where there used to be the same kind of methods.