diff --git a/Aktienhandel/Aktie.java b/Aktienhandel/Aktie.java new file mode 100755 index 0000000..2969158 --- /dev/null +++ b/Aktienhandel/Aktie.java @@ -0,0 +1,37 @@ +public class Aktie{ + private String name; + private int count; + private double value; + public Aktie(String name, int count, double value) { + this.name = name; + this.count = count; + this.value = value; + } + public double getAktienWert() { + return count * value; + } + public void anzahlErhoehen(int amt) { + this.count += amt; + } + public void anzahlVerringern(int amt) { + this.count -= (this.count < amt) ? 0 : amt; + } + public String getName() { + return this.name; + } + public int getCount() { + return this.count; + } + public double getValue() { + return this.value; + } + public void setName(String name) { + this.name = name; + } + public void setCount(int count) { + this.count = count; + } + public void setValue(int value) { + this.value = value; + } +} diff --git a/Aktienhandel/Broker.java b/Aktienhandel/Broker.java new file mode 100755 index 0000000..b4b0502 --- /dev/null +++ b/Aktienhandel/Broker.java @@ -0,0 +1,16 @@ +public class Broker extends Person { + protected double provision; + protected int clientCount; + public Broker(String name, int age, double money, double provision, int clientCount) { + super(name, age, money); + this.provision = provision; + this.clientCount = clientCount; + } + public void tradeAbwickeln(Trader trader, String aktieName, double price, int amt) { + trader.aktieKaufen(aktieName, price, amt); + this.money += this.provision; + } + public void kundenAnzeigen() { + System.out.println("Kunden: " + this.clientCount); + } +} diff --git a/Aktienhandel/DayTrader.java b/Aktienhandel/DayTrader.java new file mode 100755 index 0000000..cade848 --- /dev/null +++ b/Aktienhandel/DayTrader.java @@ -0,0 +1,15 @@ +public class DayTrader extends Trader { + protected int tradesPerDay; + protected boolean hebelTrade; + public DayTrader(String name, int age, double money, int tradesPerDay, boolean hebelTrade) { + super(name, age, money); + this.tradesPerDay = tradesPerDay; + this.hebelTrade = hebelTrade; + } + public void schnellerTrade(double profit) { + this.money += profit; + } + public void risikoEingrenzen() { + //do stuff I guess + } +} diff --git a/Aktienhandel/LangfristInvestor.java b/Aktienhandel/LangfristInvestor.java new file mode 100755 index 0000000..950bbe9 --- /dev/null +++ b/Aktienhandel/LangfristInvestor.java @@ -0,0 +1,15 @@ +public class LangfristInvestor extends Trader { + protected double dividends; + protected double investDuration; + public LangfristInvestor(String name, int age, double money, double dividends) { + super(name, age, money); + this.dividends = dividends; + } + public void dividendeErhalten(double amt) { + this.dividends += amt; + this.money += amt; + } + public void portfolioUmschichten() { + //stuff + } +} diff --git a/Aktienhandel/Main.java b/Aktienhandel/Main.java new file mode 100755 index 0000000..729161b --- /dev/null +++ b/Aktienhandel/Main.java @@ -0,0 +1,29 @@ +public class Main { + public static void main(String[] args) { + // Erstellen eines LangfristInvestors + LangfristInvestor investor = new LangfristInvestor("Lisa", 45, 20000, 10); + investor.aktieKaufen("Apple", 150, 10); + investor.dividendeErhalten(500); + investor.portfolioUmschichten(); + investor.anzeigen(); + + // Erstellen eines Brokers + Broker broker = new Broker("Paul", 50, 50000, 100, 5); + broker.tradeAbwickeln(investor, "Apple", 150, 5); + broker.kundenAnzeigen(); + + // Erstellen eines OnlineBrokers + OnlineBroker onlineBroker = new OnlineBroker("OnlineTrade", 35, 100000, 50, 1000, 10, "TradeZone"); + onlineBroker.gebuehrErheben(investor); + onlineBroker.neueKundenAkquirieren(50); + + // Erstellen eines DayTraders + DayTrader dayTrader = new DayTrader("Tom", 30, 30000, 5, true); + dayTrader.aktieKaufen("Tesla", 700, 3); + dayTrader.schnellerTrade(300); // Profit von 300 EUR durch schnellen Trade + dayTrader.aktieVerkaufen("Tesla", 720, 2); // Verkauf von 2 Tesla-Aktien + dayTrader.anzeigen(); + } +} + + diff --git a/Aktienhandel/OnlineBroker.java b/Aktienhandel/OnlineBroker.java new file mode 100755 index 0000000..8ac3d27 --- /dev/null +++ b/Aktienhandel/OnlineBroker.java @@ -0,0 +1,16 @@ +public class OnlineBroker extends Broker { + protected double platformFee; + protected String platformName; + public OnlineBroker(String name, int age, double money, double provision, int clientCount, double platformFee, String platformName) { + super(name, age, money, provision, clientCount); + this.platformFee = platformFee; + this.platformName = platformName; + } + public void gebuehrErheben(Trader trader) { + trader.geldAuszahlen(this.platformFee); + this.money += this.platformFee; + } + public void neueKundenAkquirieren(int amt) { + this.clientCount += amt; + } +} diff --git a/Aktienhandel/Person.java b/Aktienhandel/Person.java new file mode 100755 index 0000000..589f509 --- /dev/null +++ b/Aktienhandel/Person.java @@ -0,0 +1,19 @@ +public class Person { + protected String name; + protected int age; + protected double money; + public Person(String name, int age, double money) { + this.name = name; + this.age = age; + this.money = money; + } + public void geldEinzahlen(double amt) { + this.money += amt; + } + public void geldAuszahlen(double amt) { + this.money -= (this.money < amt) ? 0 : amt; + } + public void show() { + System.out.println("Name: " + name + ", Age: " + age + ", Money: " + money); + } +} diff --git a/Aktienhandel/Trader.java b/Aktienhandel/Trader.java new file mode 100755 index 0000000..f9f5d51 --- /dev/null +++ b/Aktienhandel/Trader.java @@ -0,0 +1,37 @@ +import java.util.ArrayList; + +public class Trader extends Person { + protected ArrayList aktien; + public Trader(String name, int age, double money) { + super(name, age, money); + this.aktien = new ArrayList(); + } + public void aktieKaufen(String name, double price, int amt) { + Aktie aktie = new Aktie(name, amt, price); + this.aktien.add(aktie); + this.geldAuszahlen(aktie.getAktienWert()); + } + public void aktieVerkaufen(String name, double price, int amt) { + for (Aktie aktie : this.aktien) { + if (aktie.getName() == name) { + this.geldEinzahlen(price * amt); + aktie.anzahlVerringern(amt); + break; + } + } + } + public double getPortfolioWert() { + double out = 0; + for (Aktie aktie : this.aktien) { + out += aktie.getAktienWert(); + } + return out; + } + public void anzeigen() { + String out = ""; + for (Aktie aktie : aktien) { + out += "\nAktie: " + aktie.getName() + ", Count: " + aktie.getCount() + ", Value: " + aktie.getValue(); + } + System.out.println("Name: " + name + ", Age: " + age + ", Money: " + money + out + "\nGesamtwert: " + this.getPortfolioWert()); + } +} diff --git a/Technikladen/OrderSystem.java b/Technikladen/OrderSystem.java index c111eac..5f08c11 100755 --- a/Technikladen/OrderSystem.java +++ b/Technikladen/OrderSystem.java @@ -3,9 +3,9 @@ import java.util.ArrayList; public class OrderSystem { private StorageManager systemManager; private ArrayList systemClients; - public OrderSystem(StorageManager manager, ArrayList clients) { + public OrderSystem(StorageManager manager) { this.systemManager = manager; - this.systemClients = clients; + this.systemClients = new ArrayList(); } public void addProduct(Product product) { this.systemManager.addProduct(product); @@ -52,4 +52,4 @@ public class OrderSystem { System.out.println("ID: " + product.getID() + ", Name: " + product.getName() + ", Price: " + product.getPrice() + ", Amount: " + product.getAmount()); } } -} \ No newline at end of file +} diff --git a/Technikladen/StorageManager.java b/Technikladen/StorageManager.java index 9771cad..1229c13 100755 --- a/Technikladen/StorageManager.java +++ b/Technikladen/StorageManager.java @@ -2,8 +2,8 @@ import java.util.ArrayList; public class StorageManager { private ArrayList storageProducts; - public StorageManager(ArrayList products) { - this.storageProducts = products; + public StorageManager() { + this.storageProducts = new ArrayList(); } public void addProduct(Product product) { this.storageProducts.add(product); diff --git a/Technikladen/TechStore.java b/Technikladen/TechStore.java index a11e42a..3540304 100755 --- a/Technikladen/TechStore.java +++ b/Technikladen/TechStore.java @@ -6,8 +6,8 @@ public class TechStore { System.out.print(input); } public static void main(String[] args) { - StorageManager manager = new StorageManager(new ArrayList()); - OrderSystem system = new OrderSystem(manager, new ArrayList()); + StorageManager manager = new StorageManager(); + OrderSystem system = new OrderSystem(manager); Scanner scnr = new Scanner(System.in); while (true) { p("\nInput mode: ");