package shoppingSystem;
public class Visit {
// Customer, Shop, Visitday, Price(including fee) in Dollar
private Customer money;
private Customer name;
private Customer customer;
private double walletmoney;
private double showWallet;
private Shop shop;
private static double taxamount;
private double price;
public Visit
(Customer c3, Shop s1,
String visitDay,
double p,
String pm
) { setPrice(p);
customer = c3;
shop = s1;
this.visitDay = visitDay;
visitDayFull = adjustDayName(visitDay);
setPaymentMethod(pm);
if (validateIfShopIsOpen()) {
return;
}
if (!checkPayment(getPaymentMethod())) {
return;
}
if (checkIfEnoughMoney(getPrice())) {
customer.setMoneyWallet(customer.getMoneyWallet() - getPrice());
shop.setRevenue(getPrice() + shop.getRevenue());
}
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String getPaymentMethod
() { return paymentmethod;
}
public void setPaymentMethod
(String paymentmethod
) { this.paymentmethod=paymentmethod;
}
private boolean checkIfEnoughMoney(double price2) {
if (customer.getMoneyWallet() >= price2) {
return true;
} else {
System.
out.
println("I`m sorry " + customer.
getName() + " you dont have enough money. "); return false;
}
}
private boolean checkPayment
(String paymentmethod
) {
switch (paymentmethod) {
case "creditcard":
if (shop.isCreditcard() == false) {
return true;
}
default:
System.
out.
println("I`m sorry " + customer.
getName() + " we dont accept creditcards."); }
return false;
}
public double userMoney() {
return getPrice();
}
public boolean validateIfShopIsOpen() {
boolean closed = true;
switch (visitDay.trim()) {
case "Mo":
if (shop.monday) {
closed = false;
}
break;
case "Tu":
if (shop.tuesday) {
closed = false;
}
break;
case "We":
if (shop.wednesday) {
closed = false;
}
break;
case "Th":
if (shop.thursday) {
closed = false;
}
break;
case "Fr":
if (shop.friday) {
closed = false;
}
break;
case "Sa":
if (shop.saturday) {
closed = false;
}
break;
case "Su":
if (shop.sunday) {
closed = false;
}
break;
}
if (closed) {
"Im sorry " + customer.getName() + " the Shop " + shop.getShopName() + " is closed today.");
}
return closed;
}
switch (visitDay) {
case "Mo":
return "Monday";
case "Tu":
return "Tuesday";
case " We":
return "Wednesday";
case "Th":
return "Thursday";
case "Fr":
return "Friday";
case "Sa":
return "Saturday";
case "Su":
return "Sunday";
default:
return "ERROR";
}
}
public void showInformations() {
calculateTax();
System.
out.
println("Customername = " + customer.
getName() + " Shopname =" + shop.
getShopName() + " Visitday =" + visitDayFull + " Price = " + getPrice() + " $ TaxAmount = $"
+ Math.
round(shop.
getTaxrate() * 100.0) / 100.0); }
private void calculateTax() {
setTaxamount(getPrice() / (100 + shop.getTaxrate()) * shop.getTaxrate());
}
return shopname;
}
public void setShopname
(String shopname
) { this.shopname = shopname;
}
public Customer getMoney() {
return money;
}
public boolean isCreditcard() {
return shop.isCreditcard();
}
public void setMoney(Customer money) {
this.money = money;
}
public Customer getName() {
return name;
}
public void setName(Customer name) {
this.name = name;
}
public double getWalletmoney() {
return walletmoney;
}
public void setWalletmoney(double walletmoney) {
this.walletmoney = walletmoney;
}
public double getShowWallet() {
return showWallet;
}
public void setShowWallet(double showWallet) {
this.showWallet = showWallet;
}
public static double getTaxamount() {
return taxamount;
}
public static void setTaxamount(double taxamount) {
Visit.taxamount = taxamount;
}
}