HTW Berlin Medieninformatik

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


Exercise 4: Abstract Data Types

Finger Exercises

Please think through the following questions before coming to the lab. Write down your answers and bring them with you for check-in.

  1. How do Julian Dates work? Search the Internet for a description and put a link to the source in your report. What methods should a class that offers Julian Dates have? Write an abstract data type that expresses this.
  2. Think up some good test cases for testing a JulianDate collection of classes. But what is a test case? A pair (input, expected output). That means, that you have to figure out before running the code what the program should output. Include some of the arithmetic methods I hope you specified in the last finger exercise such as daysBetween, tomorrow and yesterday. If you didn't - go back and include them.  

 


Lab exercises: This did not work last time. They did not understand what they were to be doing!

These are the required exercises for this week. Work in groups of two, and turn in just one report for the group.

  1. Implement the abstract data type Julian Date you specified in the prelab as a class. If you are missing any methods, explain in your report how you figured out that they were missing, and how you implemented them.
  2. Now make a little program that uses your Julian Date class. The program should ask for a birthday and figure out how many days old the person is and what weekday they were born on. If today is their birthday, then write out a special message. If you have lived a number of days that is divisible by 100, print a special message! Check your program using both of your birthdays. Which of you is the oldest? Is there a Sunday's Child?
  3. A metric system is proposed to reform the calendar. It will have 10 regular days are a week, 10 weeks a month, 10 months a year. Extend your JulianDate class to a class MetricDate that has a method for converting from JulianDate to metric and from metric to JulianDate. How old are both of you on this metric system?

For the bored:

  1. Make an applet that uses the Julian Date and requests the user to input their birthday. If today is their birthday, then play some "Happy Birthday" song you find on the web. Who has the rights to this music, if you were going to use it online? Or is this in the public domain? You can display a cake with a candles animation on it...
  2. Extend the JulianDate class to use a locale to determine the language and date style and then supply a readValidDate() method which will conduct a dialogue in the appropriate language as determined by the locale, and not return until a valid date has been entered. Implement at least two different languages.
  3. (If you have a lot of time on your hands) Extend the JulianDate class to support a third locale, called ISO, which outputs the date in the format yyyy-mm-dd. This format is the ISO standard and is useful since sorting dates on this format will place them into ascending date order.
  4. (If you have no social life outside of this class) Extend the JulianDate class with toString() methods that respect the locale and give proper month and weekday names in the appropriate languages.

Your report is due by 11.00 pm the evening before your next lab! As in Informatics 1, I am more interested in process than in product, although we are now getting more interested in products as well. Your report should include any collaborators, summarize what you learned, and note the time you invested in this exercise. How many lines of code did you write for each exercise? Record this in your report.


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