Skip to content

Commit 643288e

Browse files
committed
Some updates to customer functions
1 parent 5b7b1a5 commit 643288e

File tree

4 files changed

+31
-13
lines changed

4 files changed

+31
-13
lines changed

{code}pendent/src/Customer.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class Customer {
2020
}
2121

2222
public String toString(){
23-
return "ID: "+ this.customerId+ ", Name: "+this.name;
23+
return "\n" + "ID: "+ this.customerId+ ", Name: " + this.name;
2424
}
2525

2626
public Customer addCustomer(){
@@ -32,8 +32,17 @@ public Customer addCustomer(){
3232
Customer newCustomer = new Customer(customerID, customerName);
3333
return newCustomer;
3434
}
35-
public void removeCustomer(){
3635

36+
public int getCustomerId() {
37+
return customerId;
38+
}
39+
40+
public void setCustomerId(int customerId) {
41+
this.customerId = customerId;
42+
}
43+
44+
public String removeCustomer(){
45+
return null;
3746
}
3847

3948

{code}pendent/src/DartController.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ public void addCustomer(){
2626
this.customerList.add(customer.addCustomer());
2727
System.out.println(customerList.toString());
2828
}
29+
30+
public void removeCustomer(){
31+
int removeId = helper.getInt("ID of customer to remove: ");
32+
// String toRemove = customer.removeCustomer(removeId);
33+
this.customerList.removeIf(customer -> customer.getCustomerId() == removeId);
34+
viewCustomer();
35+
}
2936
public void viewCustomer(){
3037
for (Customer customer : customerList) {
3138
System.out.println(customer.toString());
@@ -36,9 +43,11 @@ public void viewCustomer(){
3643
public Customer getCustomer(){
3744
return customer;
3845
}
46+
3947
public void setCustomer(){
4048
this.customer = customer;
4149
}
50+
4251
// Talking to employee
4352
//--------------------------------------------------------------------------//
4453
public void addEmployee(){
@@ -73,13 +82,12 @@ public void run() {
7382
menu.mainMenu();
7483
}
7584

76-
}
7785

78-
/* public void initialiseCustomerArraylist(){
79-
System.out.println("Checcccccccccccccccccccccck");
80-
setCustomers().add( new Customer(1,"Vernita"));
81-
getCustomers().add( new Customer(2,"Navya"));
82-
getCustomers().add( new Customer(3,"Drake"));
83-
getCustomers().add( new Customer(4,"Altan"));
84-
setCustomers().add( new Customer(5,"Axel"));
85-
}*/
86+
public void initialiseCustomerArraylist(){
87+
customerList.add( new Customer(1,"Vernita"));
88+
customerList.add( new Customer(2,"Navya"));
89+
customerList.add( new Customer(3,"Drake"));
90+
customerList.add( new Customer(4,"Altan"));
91+
customerList.add( new Customer(5,"Axel"));
92+
}
93+
}

{code}pendent/src/Menus.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,13 @@ public void employeeMenu() {
154154
break;
155155
case "7":
156156
System.out.println("Register Customer");
157+
dartController.initialiseCustomerArraylist();
157158
dartController.addCustomer();
158159
employeeMenu();
159160
break;
160161
case "8":
161162
System.out.println("Remove Customer");
162-
System.out.println("add the method for now returns you to main menu");
163+
dartController.removeCustomer();
163164
mainMenu();
164165
break;
165166
case "9":

{code}pendent/{code}pendent.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<content url="file://$MODULE_DIR$">
66
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
77
</content>
8-
<orderEntry type="jdk" jdkName="14" jdkType="JavaSDK" />
8+
<orderEntry type="inheritedJdk" />
99
<orderEntry type="sourceFolder" forTests="false" />
1010
</component>
1111
</module>

0 commit comments

Comments
 (0)