This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import javax.swing.*; | |
| import java.awt.*; | |
| import java.awt.event.ActionEvent; | |
| import java.awt.event.ActionListener; | |
| class ButtonToggleApp extends JFrame implements ActionListener { | |
| private JButton button; | |
| private Timer colorTimer; | |
| private boolean isRunning = false; | |
| private boolean isRed = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyException extends Exception { | |
| public MyException(String msg) { | |
| super(msg); | |
| } | |
| } | |
| class Throw { | |
| public static int part(int x) throws MyException { | |
| if (x == 0) | |
| throw new MyException("Division by zero"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ============================================================================ | |
| // AUFGABE 3 - Clase abstracte si mostenire | |
| // ============================================================================ | |
| // a) Abstract base class | |
| abstract class Routenelement { | |
| public abstract int getLaenge(); | |
| } | |
| // Concrete implementations |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| RĂSPUNSURI pentru Exercițiul 2 - Analiza vizibilității: | |
| 1: return mb2; în clasa A | |
| - PERMIS: mb2 este protected în B, iar A extinde B, deci A poate accesa membrii protected ai lui B | |
| 2: return mb1 + b.mb1; în clasa B | |
| - PERMIS: mb1 este private în B, dar îl accesăm din cadrul aceleiași clase B | |
| 3: return b1 + c.mc; în clasa B |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ============================================================================ | |
| // AUFGABE 1 - Polymorphism and Method Overriding | |
| // ============================================================================ | |
| // Class diagram shows: | |
| class A { | |
| public void meth() { | |
| System.out.println("Method from class A"); | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //javac --module-path ~/javafx-sdk/lib --add-modules javafx.controls GuiAufgabe.java | |
| import javafx.application.Application; | |
| import javafx.geometry.Insets; | |
| import javafx.geometry.Pos; | |
| import javafx.scene.Scene; | |
| import javafx.scene.control.Button; | |
| import javafx.scene.control.Label; | |
| import javafx.scene.control.TextField; | |
| import javafx.scene.layout.GridPane; | |
| import javafx.scene.layout.HBox; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Iterator; | |
| class Range implements Iterable<Integer>, Iterator<Integer> { | |
| private int current; | |
| private int end; | |
| private int step; | |
| public Range(int init, int end, int step) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| //clasa adresa | |
| class Adresse { | |
| private String ort; | |
| private String plz; | |
| private String strasse; | |
| private String hausNr; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Aufgabe 1) b) | |
| public class ExceptionHandlingTest { | |
| static public void setzeFarbe(String farbe) throws Exception { | |
| if (!farbe.equals("rot") && !farbe.equals("blau")) | |
| throw new Exception("Ungueltige Farbe " + farbe); | |
| System.out.println("Setze Farbe " + farbe + "!"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| import java.util.stream.*; | |
| //clasa Student | |
| class Student { | |
| private String name; | |
| private int alter; | |
| private int matrikelNr; |