ERLEDIGT
NEIN
NEIN
ANTWORTEN
1
1
ZUGRIFFE
452
452
EMPFEHLEN
-
public class Shopping {
/** Konstruktor von Shopping **//
public Shopping () {
}
public void goShopping (int day, int hour, int minute) {}
}
Diese Klasse sol so erweitert werden, dass die Methode goShopping an Sonntagen (day == 7) und zwischen 20 und 8 Uhr mit einer neu programmierten Exception ShopsClosedException abgebrochen wird.
Zusätzlich soll eine main-Methode eingefügt werden, die folgenden Code ausführt:
Shopping food = new Shopping();
food.goShopping (6, 15, 45);
food.goShopping (4, 13, 11);
food.goShopping (7, 9, 15);
-
07.12.03 20:17 #2
- Registriert seit
- Nov 2001
- Ort
- Gießen
- Beiträge
- 4.091
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
public class Shopping { public Shopping() { } public void goShopping(int day, int hour, int minute) throws ShopsClosedException { if((day == 7) || (hour < 8) || (hour > 20)) { throw new ShopsClosedException(); } // Laden ist noch offen } public static void main(String[] args) { try { Shopping food = new Shopping(); food.goShopping (6, 15, 45); food.goShopping (4, 13, 11); food.goShopping (7, 9, 15); } catch(ShopsClosedException e) { // ... } } }"You could say that I was too lazy to calculate and so I invented the computer." -- Konrad Zuse
Ähnliche Themen
-
Exceptions
Von schiese im Forum Java GrundlagenAntworten: 5Letzter Beitrag: 24.08.10, 17:50 -
Exceptions
Von TheTank im Forum VisualStudio & MFCAntworten: 1Letzter Beitrag: 28.07.10, 07:43 -
Exceptions
Von lernen.2007 im Forum JavaAntworten: 1Letzter Beitrag: 14.06.06, 13:17 -
Exceptions
Von lernen.2007 im Forum JavaAntworten: 9Letzter Beitrag: 17.12.05, 18:14 -
Exceptions wie in Java
Von MD1978 im Forum .NET ArchivAntworten: 12Letzter Beitrag: 24.01.05, 17:27





Zitieren
Login





