Compare commits
23 Commits
89bb3a674e
...
75d4d3e627
Author | SHA1 | Date | |
---|---|---|---|
75d4d3e627 | |||
c6fdc4b093 | |||
08cbf4a7f5 | |||
be65e3e445 | |||
0aff196b75 | |||
5bc96cfa36 | |||
2416f27d17 | |||
b871ab9a85 | |||
df521054ef | |||
f9fc852421 | |||
2694e7b7b0 | |||
1e9ecee355 | |||
ed9f84a466 | |||
a5fea77649 | |||
bb83044c78 | |||
fdb1719171 | |||
f66f633416 | |||
ddc485ddeb | |||
192ae021dc | |||
c2f1ec6efd | |||
ef25b53add | |||
6dc6d1aa57 | |||
e51bfa3350 |
37
Aktienhandel/Aktie.java
Executable file
37
Aktienhandel/Aktie.java
Executable file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
16
Aktienhandel/Broker.java
Executable file
16
Aktienhandel/Broker.java
Executable file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
15
Aktienhandel/DayTrader.java
Executable file
15
Aktienhandel/DayTrader.java
Executable file
@ -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
|
||||||
|
}
|
||||||
|
}
|
15
Aktienhandel/LangfristInvestor.java
Executable file
15
Aktienhandel/LangfristInvestor.java
Executable file
@ -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
|
||||||
|
}
|
||||||
|
}
|
29
Aktienhandel/Main.java
Executable file
29
Aktienhandel/Main.java
Executable file
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
16
Aktienhandel/OnlineBroker.java
Executable file
16
Aktienhandel/OnlineBroker.java
Executable file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
19
Aktienhandel/Person.java
Executable file
19
Aktienhandel/Person.java
Executable file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
37
Aktienhandel/Trader.java
Executable file
37
Aktienhandel/Trader.java
Executable file
@ -0,0 +1,37 @@
|
|||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Trader extends Person {
|
||||||
|
protected ArrayList<Aktie> aktien;
|
||||||
|
public Trader(String name, int age, double money) {
|
||||||
|
super(name, age, money);
|
||||||
|
this.aktien = new ArrayList<Aktie>();
|
||||||
|
}
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
@ -3,9 +3,9 @@ import java.util.ArrayList;
|
|||||||
public class OrderSystem {
|
public class OrderSystem {
|
||||||
private StorageManager systemManager;
|
private StorageManager systemManager;
|
||||||
private ArrayList<Client> systemClients;
|
private ArrayList<Client> systemClients;
|
||||||
public OrderSystem(StorageManager manager, ArrayList<Client> clients) {
|
public OrderSystem(StorageManager manager) {
|
||||||
this.systemManager = manager;
|
this.systemManager = manager;
|
||||||
this.systemClients = clients;
|
this.systemClients = new ArrayList<Client>();
|
||||||
}
|
}
|
||||||
public void addProduct(Product product) {
|
public void addProduct(Product product) {
|
||||||
this.systemManager.addProduct(product);
|
this.systemManager.addProduct(product);
|
||||||
|
@ -2,8 +2,8 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class StorageManager {
|
public class StorageManager {
|
||||||
private ArrayList<Product> storageProducts;
|
private ArrayList<Product> storageProducts;
|
||||||
public StorageManager(ArrayList<Product> products) {
|
public StorageManager() {
|
||||||
this.storageProducts = products;
|
this.storageProducts = new ArrayList<Product>();
|
||||||
}
|
}
|
||||||
public void addProduct(Product product) {
|
public void addProduct(Product product) {
|
||||||
this.storageProducts.add(product);
|
this.storageProducts.add(product);
|
||||||
|
@ -6,8 +6,8 @@ public class TechStore {
|
|||||||
System.out.print(input);
|
System.out.print(input);
|
||||||
}
|
}
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
StorageManager manager = new StorageManager(new ArrayList<Product>());
|
StorageManager manager = new StorageManager();
|
||||||
OrderSystem system = new OrderSystem(manager, new ArrayList<Client>());
|
OrderSystem system = new OrderSystem(manager);
|
||||||
Scanner scnr = new Scanner(System.in);
|
Scanner scnr = new Scanner(System.in);
|
||||||
while (true) {
|
while (true) {
|
||||||
p("\nInput mode: ");
|
p("\nInput mode: ");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user