-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerson.java
123 lines (103 loc) · 2.68 KB
/
Person.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import java.lang.Math;
public class Person
{
private int money;
private int receivedMoney;
private int paidMoney;
private String name="";
private Product product = new Product();
Person(){
money=0;
receivedMoney=0;
paidMoney=0;
}
Person(int money){
this.money = money;
receivedMoney = 0;
paidMoney = 0;
this.name = "";
}
Person(int money, String name){
this.money = money;
receivedMoney = 0;
paidMoney = 0;
this.name = name;
}
Person(String rand){
double randMoney = Math.random() * 1000;
this.money = (int)randMoney;
receivedMoney = 0;
paidMoney = 0;
this.name = "";
}
public int getProductPrice(){
int price = product.returnPrice();
return price;
}
public int getProductStock(){
int stock = product.returnStock();
return stock;
}
public String getProductName(){
String name = product.returnName();
return name;
}
public int getProductType(){
int type = product.returnType();
return type;
}
public void name(String name){
this.name = name;
}
public void payMoney(int money)
{
this.money = this.money - money;
this.paidMoney = this.paidMoney + money;
}
public void receiveMoney(int money)
{
this.money = this.money + money;
this.receivedMoney = this.receivedMoney + money;
}
public boolean validTransaction(int money){
if (this.money - money > 0){
return true;
}
else {
return false;
}
}
public boolean isPositive(){
if (this.money >= 0){
return true;
}
else
{
return false;
}
}
public void productInfo(){
String[] productArr = new String[3];
productArr = product.productStatus();
if (productArr[0].length() > 0){
System.out.println("Name: " + productArr[0] +
" Price: " + productArr[1] + " Stock: " +
productArr[2] + " Type: " + productArr[3]);
}
else {
System.out.println("Price: " + productArr[1]
+ " Stock: " + productArr[2] + " Type: "
+ productArr[3]);
}
}
public void values(){
if (this.name.length() > 0){
System.out.println(this.name);
}
System.out.println("Money: " + money);
System.out.println("Received Money: " + receivedMoney);
System.out.println("Paid Monay: " + paidMoney);
this.productInfo();
System.out.println();
}
}