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()); + } +}