Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo!!

Seht euch das mal an:

8pok-s.jpg

Da ich mit Eclipse arbeite und nicht sicher bin, ob es nicht daran liegt, hab ich nen Screen gemacht.

Wenn ich

k[0] = new Quader(3.0, 2.0, 1.0);

k[1] = new Quader(1.0,2.0,2.0);

k[2] = new Zylinder(3.0,2.0);

k[3] = new Zylinder(2.0,3.0);

k[4] = new Kugel(2.0);

k[5] = new Kugel(4.0);

lösche, kriege ich wieder eine Ausgabe. Was ist das los?

Grüße

rascalize

public Quader(double laenge, double breite, double hoehe){

this.laenge = laenge;

this.breite = breite;

this.hoehe = hoehe;

if (laenge < 0 | hoehe < 0 | breite < 0)

System.out.print("Es wurde ein negativer Wert eingegeben. Programm wird beendet!");

System.exit(1);

}

public Kugel(double radius){

this.radius = radius;

if(radius<0)

System.out.print("Es wurde ein negativer Wert eingegeben. Programm wird beendet!");

System.exit(1);

}

public Zylinder(double radius, double hoehe){

this.radius = radius;

this.hoehe = hoehe;

if (hoehe < 0 | radius < 0)

if (radius < 0 | hoehe < 0)

System.out.print("Es wurde ein negativer Wert eingegeben. Programm wird beendet!");

System.exit(1);

}

Edit: Auf Konsole das gleiche Problem: Keine Ausgabe, solange ich Felder definiere.

Meine Konstruktoren sind doch aber in Ordnung, oder nicht?

Bearbeitet von Rascal

Ich denke mal nicht, dass deine Konstruktoren in Ordnung sind, weil egal was passiert, dein Programm wird immer beendet sobald du einen Kontruktor ausführst, weil dein "System.exit(1);" immer ausgeführt wird, da es nicht mehr zur If-Anweisung gezählt wird.

Wie oft ich da drüber hinweggelesen habe. Das es sowas banales, wie Klammern sind...

ich danke dir!!

Sind es nicht fast immer klammern oder irgendwelche punkte? ;-)

Wie wahr :rolleyes:

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.