-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.java
More file actions
185 lines (141 loc) · 5.02 KB
/
User.java
File metadata and controls
185 lines (141 loc) · 5.02 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package oopProject;
import java.util.ArrayList;
/**
*
* @author Melda
*/
public class User {
private String userName;
private String name;
private String surname;
private String dateOfBirth;
private String password;
private String email;
private String homeAddress;
private String workAddress;
private int quantity;
private ArrayList<Product> productsOrdered= new ArrayList<>();;
private ArrayList<Product> favoriteProducts= new ArrayList<>();;
private ArrayList<CreditCard> creditCard= new ArrayList<>();;
private ArrayList<Integer> quantities = new ArrayList<>();
public User(String userName, String name, String surname, String dateOfBirth, String password, String email, String homeAddress, String workAddress){
this.userName = userName;
this.name = name;
this.surname = surname;
this.dateOfBirth = dateOfBirth;
this.password = password;
this.email = email;
this.homeAddress = homeAddress;
this.workAddress = workAddress;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public String getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(String dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getHomeAddress() {
return homeAddress;
}
public void setHomeAddress(String homeAddress) {
this.homeAddress = homeAddress;
}
public String getWorkAddress() {
return workAddress;
}
public void setWorkAddress(String workAddress) {
this.workAddress = workAddress;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public Integer getQuantities(int index){
return this.quantities.get(index);
}
public Product getProductsOrderedByIndex(int index){
return this.productsOrdered.get(index);
}
public Product getFavoriteProductsByIndex(int index){
return this.favoriteProducts.get(index);
}
public CreditCard getCreditCardByIndex(int index){
return this.creditCard.get(index);
}
public void productOrdering(Product p, int quantity, CreditCard c, String address){
this.quantity= quantity;
if((quantity<=p.getNumberOfStocks()) && (quantity>0)){
productsOrdered.add(p);
quantities.add(quantity);
if(!creditCard.contains(c)){
creditCard.add(c);
}
System.out.println("\n\n-------------------------------");
System.out.println("\nYour Order Informations: ");
System.out.println(p.getProductName() + " x" + quantity + " " + p.getPrice()*quantity + "TL\n" );
System.out.println("Credit Card Number: ************" + c.getCreditCardNumber().substring(12));
System.out.println("Adress Information For This Order: " + address);
System.out.println("\n------------------------------\n\n");
}
}
public void productFavorite(Product p){
if(!favoriteProducts.contains(p)){
favoriteProducts.add(p);
}
}
public void viewProfile(){
System.out.println("\n\n"+getName()+" "+getSurname()+"'s Account\n");
System.out.println("Your favorite products: ");
for(Product p : favoriteProducts){
System.out.println(p.getProductName()+" ");
}
System.out.println();
System.out.println("Your ordered products: ");
for(int i = 0; i < productsOrdered.size(); i++){
Product p = getProductsOrderedByIndex(i);
int q = getQuantities(i);
System.out.println(p.getProductName() + " x" + q);
}
System.out.println();
System.out.println("Your credit cards: ");
for(CreditCard c : creditCard){
System.out.println(c.getCreditCardNumber() + " ");
}
}
}