Question: Where the updated code for the store class and item class class Item { private String name; private int price; / / in pence /

Where the updated code for the store class and item class
class Item {
private String name;
private int price; // in pence
// Constructor
public Item(String name, int price){
this.name = name;
this.price = price;
}
// Accessor Methods
public String getName(){
return name;
}
public int getPrice(){
return price;
}
public String getPriceString(){
return price 100? price +"p" : (price /100)+""+(price & 100)+"p";
}
}
```
class Store {
private String storeName;
private int total; // Total money taken at checkout
// Constructor
public Store(String storeName){
this.storeName = storeName;
this.total =0;
}
// Member Registration Method 1
public void memberRegisterl(Member member){
System.out.println(storeName +" welcomes "+ member.getName()+
"(id:"+ member.getId()+")");
member.setStore(this); // Link the store to the member
}
// Member Registration Method 2
public void memberRegister2(String name, String id, String pinNumber){
Member member = new Member(name, id, pinNumber);
System.out.println(storeName +" welcomes "+ member.getName()+
"(id:"+ member.getId()+")");
member.setStore(this); // Link the store to the member
}
// Checkout Method
public void checkout(int payment, Member member){
Item item = member.getSelectedItem();
if (item == null){
System.out.println("No item selected.");
return;
}
System.out.println(storeName +": Serving "+ member.getName());
System.out.println("Your basket contains");
System.out.println(item.getName()+" at "+ item.getPriceString());
System.out.println("You have tendered "+ payment +"p");
int change = payment - item.getPrice();
if (change 0){
System.out.println("Not enough money tendered.");
return;
}
System.out.println("Your change is "+ change +"p");
member.reduceMoney(item.getPrice());
total += item.getPrice();
}
}
```
Where the updated code for the store class and

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!