Aktienhandel #4
@ -1,44 +1,42 @@
|
||||
package tech_store;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Order {
|
||||
private int orderClientID;
|
||||
private ArrayList<OrderEntry> orderEntries;
|
||||
private String orderDate;
|
||||
public Order(int clientID, String date) {
|
||||
this.orderClientID = clientID;
|
||||
this.orderEntries = new ArrayList<OrderEntry>();
|
||||
this.orderDate = date;
|
||||
}
|
||||
public int getClientID() {
|
||||
return this.orderClientID;
|
||||
}
|
||||
public String getDate() {
|
||||
return this.orderDate;
|
||||
}
|
||||
public ArrayList<OrderEntry> getEntries() {
|
||||
return this.orderEntries;
|
||||
}
|
||||
public void addEntry(OrderEntry entry) {
|
||||
this.orderEntries.add(entry);
|
||||
}
|
||||
public int calcPrice() {
|
||||
int price = 0;
|
||||
for (OrderEntry entry : this.orderEntries) {
|
||||
price += entry.calcPrice();
|
||||
}
|
||||
return price;
|
||||
}
|
||||
public String createReceipt() {
|
||||
String output = "\n";
|
||||
for (OrderEntry entry : this.orderEntries) {
|
||||
output += entry.toString() + ", Price: " + entry.calcPrice() + "\n";
|
||||
}
|
||||
output += "=====" + this.calcPrice() + "=====";
|
||||
return output;
|
||||
}
|
||||
public String toString() {
|
||||
return ("Client: " + this.orderClientID + ", Date: " + this.orderDate);
|
||||
}
|
||||
}
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Order {
|
||||
private int orderClientID;
|
||||
private ArrayList<OrderEntry> orderEntries;
|
||||
private String orderDate;
|
||||
public Order(int clientID, String date) {
|
||||
this.orderClientID = clientID;
|
||||
this.orderEntries = new ArrayList<OrderEntry>();
|
||||
this.orderDate = date;
|
||||
}
|
||||
public int getClientID() {
|
||||
return this.orderClientID;
|
||||
}
|
||||
public String getDate() {
|
||||
return this.orderDate;
|
||||
}
|
||||
public ArrayList<OrderEntry> getEntries() {
|
||||
return this.orderEntries;
|
||||
}
|
||||
public void addEntry(OrderEntry entry) {
|
||||
this.orderEntries.add(entry);
|
||||
}
|
||||
public int calcPrice() {
|
||||
int price = 0;
|
||||
for (OrderEntry entry : this.orderEntries) {
|
||||
price += entry.calcPrice();
|
||||
}
|
||||
return price;
|
||||
}
|
||||
public String createReceipt() {
|
||||
String output = "\n";
|
||||
for (OrderEntry entry : this.orderEntries) {
|
||||
output += entry.toString() + ", Price: " + entry.calcPrice() + "\n";
|
||||
}
|
||||
output += "=====" + this.calcPrice() + "=====";
|
||||
return output;
|
||||
}
|
||||
public String toString() {
|
||||
return ("Client: " + this.orderClientID + ", Date: " + this.orderDate);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user