Homework 9

Due Thurs, Jan 20, 18:00

Part I

Exercise 1:  (4 points)

Create a class HourlyWorker that implements the Worker interface:
Write a junit test class HourlyWorkerTest.java with at least 3 tests that make sure that the computePay method returns the correct amount for hours worked (<40, ==40, >40).

Part II
For this part, you will create a class to represent German regular verbs with methods to return the word forms needed to conjugate in the present tense (1st, 2nd, 3rd singular and plural forms), and to return the past participle. Your class will be able to deal with the special cases of words ending in "ier", "t", and "d".

Exercise 2:  (6 points)

German verbs are conjugated in the present tense by adding endings to the stem (e, st, t, en, t, en).
The past participle is usually formed by adding the prefix "ge" and the suffix "t" to the stem:
gespielt

Exceptions:
If the stem ends with "d" or "t":
An extra "e" is inserted before the ending for the du, er/sie/es, and ihr forms when conjugating:
du arbeitest
er arbeitet
ihr arbeitet
An extra "e" is inserted when forming the past participle:
gearbeitet

If the stem ends with "ier":
The past participle is formed by simply adding the suffix "t" to the stem:
probiert


Summary:

spielen
(stem spiel):
probieren
(stem probier):
arbeiten
(stem arbeit):
ich spiele probiere arbeite
du
spielst probierst arbeitest
er/sie/es
spielt probiert arbeitet
wir
spielen probieren arbeiten
ihr
spielt probiert arbeitet
sie
spielen probieren arbeiten




Past participle:
gespielt probiert gearbeitet


Create a class GermanRegVerb which extends the abstract class GermanVerb :
Notes:
Use GermanRegVerbTest.java to test your code.
Use GermanRegVerbDemo.java to try your code with words of your own choice.



Extra Challenge (optional exercise)

German verbs are separable if they start with certain prefixes:

zusammen, fort, nach, auf, aus, bei, ein, mit, vor, weg, an, ab, zu (there may be more).

Examples:
abspielen, nachmachen, aufstehen, ausprobieren...

Separable verbs are conjugated in the present tense the same way as regular verbs, but with the prefix added at the end as a separate word.

The past participle is formed in the same way as for regular verbs, but with the prefix added at the front:
abgespielt
ausprobiert

Summary:
Notice that this table is identical to the one above, with prefixes added.

abspielen
stem: spiel
prefix: ab
ausprobieren
stem: probier
prefix: aus
aufarbeiten
stem: arbeit
prefix: auf
ich spiele ab
probiere aus arbeite auf
du
spielst ab probierst aus arbeitest auf
er/sie/es
spielt ab probiert aus arbeitet auf
wir
spielen ab probieren aus arbeiten auf
ihr
spielt ab probiert aus arbeitet auf
sie
spielen ab probieren aus arbeiten auf




Past participle:
abgespielt ausprobiert aufgearbeitet


Modify your GermanRegVerb to handle separable verbs.

Requirements: Hint:

Test with GermanRegVerbTest2.java.
Use the demo program from exercise 2 to try your code with words of your own choice.



Submit the following files to Anne (javaiscl (at googlemail.com)):
HourlyWorker.java
HourlyWorkerTest.java
GermanRegVerb.java