HTW Berlin Medieninformatik

HTW Berlin
Fachbereich 4
Internationaler Bachelor Studiengang
Internationale Medieninformatik (Bachelor)
Info 2: Informatik II
Summer Term 2023


Exercise 9: Fun with Calculators 3

Finger exercises
  1. We are now going to make a calculator for a different data type that just integers. 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. You will be producing a date calculator. 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 in an emergency 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 calculator?
  2. How do you get your 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. Or you can extend your Calculator to be able to do decimal, hex, and your chosen data type!
  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 ....
Each member of the pair of you submits the same report. Remember to include a report on how the pair programming went! Your reports are due by 22.00 next week.


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