HTW Berlin Medieninformatik

HTW Berlin
Fachbereich 4
Internationaler Studiengang
Internationale Medieninformatik (Bachelor)
Info 2: Informatik II
Winter Term 2009/10


Exercise 8: Fun with Calculators - Week 3

Finger exercises
  1. We are then going to make a calculator for a different data type that just ints. Of course, the bored are welcome to implement any fascinating new data types they can think up for using a calculator with! Choose one of the following data types:
    1. Either polish your extended JulianDate class or see if one of the bored has made something useful. Make sure that you can read and write dates in a specific format. Add methods such as public void addDays (int days); if necessary. Decide how you are going to map functions such as adding or subtracting a number of days to a date, determining the number of days between a date, and determining the weekday to the buttons +, -, *, and /.
    2. You can either implement your own set, or use the Java Set data type to implement your set calculator. How are you going to do the input? Start with just sets of single digits. {1, 3} + {1, 4} = {1, 3, 4}. How are you going to map the functions such as adding, subtraction, or intersecting sets to the buttons on the calcualtor?
  2. How do you get the calculator to accept input of your chosen data type and to display output of the chosen type?
     

Lab exercises

  1. Make another new copy of the Calculator (don't wreck your previous versions) before you start.
  2. If you are doing the date calculator, implement the following functions:
    1. input a date
    2. get the calculator to display a String for the weekday in the window (hint: you will need a button to push)
    3. add a number of days to a date, displaying the new date
    4. subtract a number of days from a date, displaying the new date
    5. subtract two dates, giving the number of days between the dates
  3. If you are doing the set calculator, implement the following funcitons:
    1. input a set
    2. get the calculator to display the number of elements in the set (hint: you will need a button to push)
    3. add two sets, displaying the result set (this function is commonly called the union)
    4. subtract one set from another
    5. calculate the intersection of two sets
    6. The bored can make a power set function.

For the bored:

  1. Have variations for the date display format: German, American, ISO
  2. Add buttons to your fancy calculator for switching locale for the dates. Now include a button that, when pressed, speaks the number or word currently on the display of your calculator. Blinking lights are not necessary, but maybe you can make it skinable. It does look like it is going to rain this weekend though ....
Work in groups of two, each of you submits the same report, detailing who did what part of the work. Your reports are due by 23.00 next week.


Copyright 2009 Prof. Dr. Debora Weber-Wulff
Questions or comments: <weberwu@htw-berlin.de>
Some rights reserved. - Copyright and Warranty