diff --git a/.vscode/launch.json b/.vscode/launch.json index 47d9d17..877860a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,5 +1,11 @@ { "configurations": [ + { + "type": "java", + "name": "CodeLens (Launch) - App", + "request": "launch", + "mainClass": "app.App" + }, { "type": "java", "name": "CodeLens (Launch) - App", diff --git a/de.hhn.ai.prog2.blatt3.gui/.classpath b/de.hhn.ai.prog2.blatt3.gui/.classpath new file mode 100644 index 0000000..51a8bba --- /dev/null +++ b/de.hhn.ai.prog2.blatt3.gui/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/de.hhn.ai.prog2.blatt3.gui/.project b/de.hhn.ai.prog2.blatt3.gui/.project new file mode 100644 index 0000000..fec8c95 --- /dev/null +++ b/de.hhn.ai.prog2.blatt3.gui/.project @@ -0,0 +1,17 @@ + + + de.hhn.ai.prog2.blatt3.gui + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/de.hhn.ai.prog2.blatt3.gui/.settings/org.eclipse.jdt.core.prefs b/de.hhn.ai.prog2.blatt3.gui/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..0c68a61 --- /dev/null +++ b/de.hhn.ai.prog2.blatt3.gui/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/de.hhn.ai.prog2.blatt3.gui/.vscode/launch.json b/de.hhn.ai.prog2.blatt3.gui/.vscode/launch.json new file mode 100644 index 0000000..29cc9f9 --- /dev/null +++ b/de.hhn.ai.prog2.blatt3.gui/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "Debug (Launch) - Current File", + "request": "launch", + "mainClass": "${file}" + }, + { + "type": "java", + "name": "Debug (Launch)-App", + "request": "launch", + "mainClass": "app.App", + "projectName": "de.hhn.ai.prog2.blatt3.gui" + } + ] +} \ No newline at end of file diff --git a/de.hhn.ai.prog2.blatt3.gui/src/app/App.java b/de.hhn.ai.prog2.blatt3.gui/src/app/App.java new file mode 100644 index 0000000..e7e676d --- /dev/null +++ b/de.hhn.ai.prog2.blatt3.gui/src/app/App.java @@ -0,0 +1,8 @@ +package app; + +public class App { + public static void main(String[] args) throws Exception { + MyFirstJFrame myfiFirstJFrame = new MyFirstJFrame(); + myfiFirstJFrame.setVisible(true); + } +} \ No newline at end of file diff --git a/de.hhn.ai.prog2.blatt3.gui/src/app/MyFirstJFrame.java b/de.hhn.ai.prog2.blatt3.gui/src/app/MyFirstJFrame.java new file mode 100644 index 0000000..3407698 --- /dev/null +++ b/de.hhn.ai.prog2.blatt3.gui/src/app/MyFirstJFrame.java @@ -0,0 +1,51 @@ +package app; + +import java.awt.Container; +import java.awt.GridLayout; + +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JRadioButton; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.WindowConstants; + +public class MyFirstJFrame extends JFrame { + private static final long serialVersionUID = -4444568389750643191L; + + public MyFirstJFrame() { + super("Mein erstes Fenser :)"); + this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + this.setBounds(100, 100, 400, 400); + Container container = this.getContentPane(); + container.setLayout(new GridLayout(10, 2)); + // container.setLayout(new GridBagLayout()); + container.add(new JLabel("Bezeichner für Eingabefeld:")); + JTextField textField = new JTextField(20); + container.add(textField); + container.add(new JLabel("Bezeichner für Textfeld:")); + JTextArea textArea = new JTextArea(); + textArea.setLineWrap(true); + textArea.setRows(2); + container.add(textArea); + JButton button = new JButton("Schaltfläche"); + container.add(button); + container.add(new JLabel("Liste:")); + JList list = new JList(new String[] { "Option 1", "Option 2", "Option 3" }); + container.add(list); + ButtonGroup buttonGroup = new ButtonGroup(); + JRadioButton radioButton1 = new JRadioButton("weiblich"); + buttonGroup.add(radioButton1); + container.add(radioButton1); + JRadioButton radioButton2 = new JRadioButton("männlich"); + buttonGroup.add(radioButton2); + container.add(radioButton2); + JRadioButton radioButton3 = new JRadioButton("unbekannt"); + buttonGroup.add(radioButton3); + container.add(radioButton3); + // this.pack(); + } +} \ No newline at end of file diff --git a/de.hhn.ai.prog2.blatt3.pizzashop/.classpath b/de.hhn.ai.prog2.blatt3.pizzashop/.classpath new file mode 100644 index 0000000..51a8bba --- /dev/null +++ b/de.hhn.ai.prog2.blatt3.pizzashop/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/de.hhn.ai.prog2.blatt3.pizzashop/.project b/de.hhn.ai.prog2.blatt3.pizzashop/.project new file mode 100644 index 0000000..c481049 --- /dev/null +++ b/de.hhn.ai.prog2.blatt3.pizzashop/.project @@ -0,0 +1,17 @@ + + + de.hhn.ai.prog2.blatt3.pizzashop + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/de.hhn.ai.prog2.blatt3.pizzashop/.settings/org.eclipse.jdt.core.prefs b/de.hhn.ai.prog2.blatt3.pizzashop/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..0c68a61 --- /dev/null +++ b/de.hhn.ai.prog2.blatt3.pizzashop/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/de.hhn.ai.prog2.blatt3.pizzashop/.vscode/launch.json b/de.hhn.ai.prog2.blatt3.pizzashop/.vscode/launch.json new file mode 100644 index 0000000..4380105 --- /dev/null +++ b/de.hhn.ai.prog2.blatt3.pizzashop/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "Debug (Launch) - Current File", + "request": "launch", + "mainClass": "${file}" + }, + { + "type": "java", + "name": "Debug (Launch)-App", + "request": "launch", + "mainClass": "app.App", + "projectName": "de.hhn.ai.prog2.blatt3.pizzashop" + } + ] +} \ No newline at end of file diff --git a/de.hhn.ai.prog2.blatt3.pizzashop/src/app/App.java b/de.hhn.ai.prog2.blatt3.pizzashop/src/app/App.java new file mode 100644 index 0000000..0518caa --- /dev/null +++ b/de.hhn.ai.prog2.blatt3.pizzashop/src/app/App.java @@ -0,0 +1,7 @@ +package app; + +public class App { + public static void main(String[] args) throws Exception { + System.out.println("Hello Java"); + } +} \ No newline at end of file diff --git a/de.hhn.ai.prog2.blatt3.pizzashop/src/app/Order.java b/de.hhn.ai.prog2.blatt3.pizzashop/src/app/Order.java new file mode 100644 index 0000000..cef9f04 --- /dev/null +++ b/de.hhn.ai.prog2.blatt3.pizzashop/src/app/Order.java @@ -0,0 +1,43 @@ +package app; + +import java.util.ArrayList; +import java.util.List; + +public class Order { + private String id; + private boolean completed = false; + private List pizzas = new ArrayList(); + + public Order(List pizzas) { + this.id = "TODO:Random123"; + this.pizzas = pizzas; + } + + public String getId() { + return this.id; + } + + public boolean isCompleted() { + return this.completed; + } + + public List getPizzas() { + return this.pizzas; + } + + public void addPizza(Pizza pizza) { + pizzas.add(pizza); + } + + /** + * @param completed the completed to set + */ + public void setCompleted(boolean completed) { + this.completed = completed; + } + + @Override + public String toString() { + return "Test"; // TODO: + } +} \ No newline at end of file diff --git a/de.hhn.ai.prog2.blatt3.pizzashop/src/app/Pizza.java b/de.hhn.ai.prog2.blatt3.pizzashop/src/app/Pizza.java new file mode 100644 index 0000000..226ba82 --- /dev/null +++ b/de.hhn.ai.prog2.blatt3.pizzashop/src/app/Pizza.java @@ -0,0 +1,46 @@ +package app; + +import java.util.ArrayList; +import java.util.List; + +public class Pizza { + private String name; + private PizzaSize size; + private List toppings = new ArrayList(); + + public Pizza(String name, PizzaSize pizzaSize, List toppings) { + this.name = name; + this.size = pizzaSize; + this.toppings = toppings; + } + + public String getName() { + return this.name; + } + + public PizzaSize getSize() { + return this.size; + } + + public List getToppings() { + return this.toppings; + } + + public int getPrice() { + int price = size.getPrice(); + for (int i = 0; i < toppings.size(); i++) { + price += toppings.get(i).getPrice(); + } + return price; + } + + public void addTopping(Topping topping) { + toppings.add(topping); + } + + @Override + public String toString() { + return "Test"; // TODO: + } + +} \ No newline at end of file diff --git a/de.hhn.ai.prog2.blatt3.pizzashop/src/app/PizzaSize.java b/de.hhn.ai.prog2.blatt3.pizzashop/src/app/PizzaSize.java new file mode 100644 index 0000000..2b6fa9c --- /dev/null +++ b/de.hhn.ai.prog2.blatt3.pizzashop/src/app/PizzaSize.java @@ -0,0 +1,22 @@ +package app; + +public enum PizzaSize { + SMALL(400, "klein"), MEDIUM(500, "mittel"), LARGE(600, "groß"), FAMILY(1000, "extra groß"); + /** price in Cent */ + private int price; + /** Name in german for UI */ + private String name; + + PizzaSize(int price, String name) { + this.price = price; + this.name = name; + } + + public int getPrice() { + return this.price; + } + + public String getName() { + return name; + } +} \ No newline at end of file diff --git a/de.hhn.ai.prog2.blatt3.pizzashop/src/app/Topping.java b/de.hhn.ai.prog2.blatt3.pizzashop/src/app/Topping.java new file mode 100644 index 0000000..397e1e3 --- /dev/null +++ b/de.hhn.ai.prog2.blatt3.pizzashop/src/app/Topping.java @@ -0,0 +1,22 @@ +package app; + +public enum Topping { + CHEESE(50, "Käse"), TOMATO(25, "Tomate"), HAM(80, "Schinken"), MUSHROOM(40, "Champignon"); + /** price in Cent */ + private int price; + /** Name in german for UI */ + private String name; + + Topping(int price, String name) { + this.price = price; + this.name = name; + } + + public int getPrice() { + return this.price; + } + + public String getName() { + return name; + } +} \ No newline at end of file