Compare commits

...

23 Commits

Author SHA1 Message Date
75d4d3e627 Aktienhandel (#4)
Reviewed-on: #4
2024-10-18 18:21:54 +02:00
c6fdc4b093 cleand up function signatures 2024-10-18 18:19:16 +02:00
08cbf4a7f5 fixed Langfristinvestor 2024-10-18 18:16:21 +02:00
be65e3e445 added Aktienhandel 2024-10-18 18:12:21 +02:00
0aff196b75 revert 1e9ecee35581f80925cc7cb01ab774003500d8ce
revert cleanup signatures
2024-10-18 15:21:45 +02:00
5bc96cfa36 revert 2694e7b7b056a9ace4c40bab3c6713556a8b4d90
revert fix cleanup
2024-10-18 15:21:05 +02:00
2416f27d17 revert f9fc852421b1592983f317c56563172b3e6c7365
revert fixed stupidness
2024-10-18 15:20:22 +02:00
b871ab9a85 revert df521054ef307c0274d6dbffcea459ecbe61779e
Me dumb
2024-10-18 15:20:09 +02:00
df521054ef had to 2024-10-18 15:17:59 +02:00
f9fc852421 fixed stupidness 2024-10-15 06:24:03 +02:00
2694e7b7b0 fix cleanup 2024-10-15 06:20:09 +02:00
1e9ecee355 cleanup signatures 2024-10-15 06:17:06 +02:00
ed9f84a466 Update Technikladen/TechStore.java
Removed package line
2024-10-14 19:08:48 +02:00
a5fea77649 Update Technikladen/StorageManager.java
Removed package line
2024-10-14 19:08:10 +02:00
bb83044c78 Update Technikladen/Receipt.java
Removed package line
2024-10-14 19:07:46 +02:00
fdb1719171 Update Technikladen/Product.java
Removed package line
2024-10-14 19:07:17 +02:00
f66f633416 Update Technikladen/OrderSystem.java
Removed package line
2024-10-14 19:06:53 +02:00
ddc485ddeb Update Technikladen/OrderEntry.java
Removed package line
2024-10-14 19:06:31 +02:00
192ae021dc Update Technikladen/Order.java
Removed package line
2024-10-14 19:06:05 +02:00
c2f1ec6efd Update Technikladen/Client.java
Removed package line
2024-10-14 19:05:24 +02:00
ef25b53add Delete Technikladen/.classpath 2024-10-14 19:04:27 +02:00
6dc6d1aa57 Delete Technikladen/.project 2024-10-14 19:04:12 +02:00
e51bfa3350 added tech_store 2024-10-14 18:33:34 +02:00
11 changed files with 191 additions and 7 deletions

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

@ -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

@ -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
}
}

@ -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

@ -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

@ -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

@ -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

@ -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 {
private StorageManager systemManager;
private ArrayList<Client> systemClients;
public OrderSystem(StorageManager manager, ArrayList<Client> clients) {
public OrderSystem(StorageManager manager) {
this.systemManager = manager;
this.systemClients = clients;
this.systemClients = new ArrayList<Client>();
}
public void addProduct(Product product) {
this.systemManager.addProduct(product);

@ -2,8 +2,8 @@ import java.util.ArrayList;
public class StorageManager {
private ArrayList<Product> storageProducts;
public StorageManager(ArrayList<Product> products) {
this.storageProducts = products;
public StorageManager() {
this.storageProducts = new ArrayList<Product>();
}
public void addProduct(Product product) {
this.storageProducts.add(product);

@ -6,8 +6,8 @@ public class TechStore {
System.out.print(input);
}
public static void main(String[] args) {
StorageManager manager = new StorageManager(new ArrayList<Product>());
OrderSystem system = new OrderSystem(manager, new ArrayList<Client>());
StorageManager manager = new StorageManager();
OrderSystem system = new OrderSystem(manager);
Scanner scnr = new Scanner(System.in);
while (true) {
p("\nInput mode: ");