info-java/Aktienhandel/Aktie.java

38 lines
788 B
Java
Raw Normal View History

2024-10-18 18:12:21 +02:00
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;
}
}