fork download
  1. package shoppingSystem;
  2.  
  3. public class Visit {
  4. // Customer, Shop, Visitday, Price(including fee) in Dollar
  5.  
  6. private String shopname;
  7. private Customer money;
  8. private Customer name;
  9. private Customer customer;
  10. private double walletmoney;
  11. private double showWallet;
  12. private Shop shop;
  13. private String visitDay;
  14. private static double taxamount;
  15. private String visitDayFull;
  16. private double price;
  17. private String paymentmethod;
  18.  
  19.  
  20.  
  21.  
  22.  
  23. public Visit(Customer c3, Shop s1, String visitDay, double p, String pm) {
  24. setPrice(p);
  25. customer = c3;
  26. shop = s1;
  27. this.visitDay = visitDay;
  28. visitDayFull = adjustDayName(visitDay);
  29. setPaymentMethod(pm);
  30.  
  31. if (validateIfShopIsOpen()) {
  32. return;
  33. }
  34. if (!checkPayment(getPaymentMethod())) {
  35. return;
  36. }
  37.  
  38. if (checkIfEnoughMoney(getPrice())) {
  39. customer.setMoneyWallet(customer.getMoneyWallet() - getPrice());
  40. shop.setRevenue(getPrice() + shop.getRevenue());
  41. }
  42.  
  43. }
  44. public double getPrice() {
  45. return price;
  46. }
  47.  
  48. public void setPrice(double price) {
  49. this.price = price;
  50. }
  51. public String getPaymentMethod() {
  52. return paymentmethod;
  53. }
  54. public void setPaymentMethod(String paymentmethod) {
  55. this.paymentmethod=paymentmethod;
  56. }
  57.  
  58. private boolean checkIfEnoughMoney(double price2) {
  59. if (customer.getMoneyWallet() >= price2) {
  60. return true;
  61. } else {
  62. System.out.println("I`m sorry " + customer.getName() + " you dont have enough money. ");
  63. return false;
  64.  
  65. }
  66. }
  67.  
  68. private boolean checkPayment(String paymentmethod) {
  69.  
  70. switch (paymentmethod) {
  71. case "creditcard":
  72. if (shop.isCreditcard() == false) {
  73. return true;
  74. }
  75.  
  76. default:
  77. System.out.println("I`m sorry " + customer.getName() + " we dont accept creditcards.");
  78. }
  79. return false;
  80. }
  81.  
  82. public double userMoney() {
  83. return getPrice();
  84. }
  85.  
  86. public boolean validateIfShopIsOpen() {
  87.  
  88. boolean closed = true;
  89.  
  90. switch (visitDay.trim()) {
  91. case "Mo":
  92. if (shop.monday) {
  93. closed = false;
  94. }
  95. break;
  96.  
  97. case "Tu":
  98. if (shop.tuesday) {
  99. closed = false;
  100. }
  101. break;
  102.  
  103. case "We":
  104. if (shop.wednesday) {
  105. closed = false;
  106. }
  107. break;
  108.  
  109. case "Th":
  110. if (shop.thursday) {
  111. closed = false;
  112. }
  113. break;
  114.  
  115. case "Fr":
  116. if (shop.friday) {
  117. closed = false;
  118. }
  119. break;
  120.  
  121. case "Sa":
  122. if (shop.saturday) {
  123. closed = false;
  124. }
  125. break;
  126.  
  127. case "Su":
  128. if (shop.sunday) {
  129. closed = false;
  130. }
  131. break;
  132. }
  133.  
  134. if (closed) {
  135. System.out.println(
  136. "Im sorry " + customer.getName() + " the Shop " + shop.getShopName() + " is closed today.");
  137. }
  138. return closed;
  139. }
  140.  
  141. public String adjustDayName(String visitDay) {
  142.  
  143. switch (visitDay) {
  144. case "Mo":
  145. return "Monday";
  146.  
  147. case "Tu":
  148. return "Tuesday";
  149.  
  150. case " We":
  151. return "Wednesday";
  152.  
  153. case "Th":
  154. return "Thursday";
  155.  
  156. case "Fr":
  157. return "Friday";
  158.  
  159. case "Sa":
  160. return "Saturday";
  161.  
  162. case "Su":
  163. return "Sunday";
  164.  
  165. default:
  166. return "ERROR";
  167.  
  168. }
  169. }
  170.  
  171. public void showInformations() {
  172. calculateTax();
  173. System.out.println("Customername = " + customer.getName() + " Shopname =" + shop.getShopName() + " Visitday ="
  174. + visitDayFull + " Price = " + getPrice() + " $ TaxAmount = $"
  175. + Math.round(shop.getTaxrate() * 100.0) / 100.0);
  176. }
  177.  
  178. private void calculateTax() {
  179.  
  180. setTaxamount(getPrice() / (100 + shop.getTaxrate()) * shop.getTaxrate());
  181.  
  182. }
  183.  
  184. public String getShopname() {
  185. return shopname;
  186. }
  187.  
  188. public void setShopname(String shopname) {
  189. this.shopname = shopname;
  190. }
  191.  
  192. public Customer getMoney() {
  193. return money;
  194. }
  195.  
  196. public boolean isCreditcard() {
  197. return shop.isCreditcard();
  198. }
  199.  
  200. public void setMoney(Customer money) {
  201. this.money = money;
  202. }
  203.  
  204. public Customer getName() {
  205. return name;
  206. }
  207.  
  208. public void setName(Customer name) {
  209. this.name = name;
  210. }
  211.  
  212. public double getWalletmoney() {
  213. return walletmoney;
  214. }
  215.  
  216. public void setWalletmoney(double walletmoney) {
  217. this.walletmoney = walletmoney;
  218. }
  219.  
  220. public double getShowWallet() {
  221. return showWallet;
  222. }
  223.  
  224. public void setShowWallet(double showWallet) {
  225. this.showWallet = showWallet;
  226. }
  227.  
  228. public static double getTaxamount() {
  229. return taxamount;
  230. }
  231.  
  232. public static void setTaxamount(double taxamount) {
  233. Visit.taxamount = taxamount;
  234. }
  235.  
  236. }
  237.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:3: error: class Visit is public, should be declared in a file named Visit.java
public class Visit {
       ^
Main.java:7: error: cannot find symbol
	private Customer money;
	        ^
  symbol:   class Customer
  location: class Visit
Main.java:8: error: cannot find symbol
	private Customer name;
	        ^
  symbol:   class Customer
  location: class Visit
Main.java:9: error: cannot find symbol
	private Customer customer;
	        ^
  symbol:   class Customer
  location: class Visit
Main.java:12: error: cannot find symbol
	private Shop shop;
	        ^
  symbol:   class Shop
  location: class Visit
Main.java:23: error: cannot find symbol
	public Visit(Customer c3, Shop s1, String visitDay, double p, String pm) {
	             ^
  symbol:   class Customer
  location: class Visit
Main.java:23: error: cannot find symbol
	public Visit(Customer c3, Shop s1, String visitDay, double p, String pm) {
	                          ^
  symbol:   class Shop
  location: class Visit
Main.java:192: error: cannot find symbol
	public Customer getMoney() {
	       ^
  symbol:   class Customer
  location: class Visit
Main.java:200: error: cannot find symbol
	public void setMoney(Customer money) {
	                     ^
  symbol:   class Customer
  location: class Visit
Main.java:204: error: cannot find symbol
	public Customer getName() {
	       ^
  symbol:   class Customer
  location: class Visit
Main.java:208: error: cannot find symbol
	public void setName(Customer name) {
	                    ^
  symbol:   class Customer
  location: class Visit
Main.java:92: error: illegal start of type
			if (shop.monday) {
			   ^
Main.java:98: error: illegal start of type
			if (shop.tuesday) {
			   ^
Main.java:104: error: illegal start of type
			if (shop.wednesday) {
			   ^
Main.java:110: error: illegal start of type
			if (shop.thursday) {
			   ^
Main.java:116: error: illegal start of type
			if (shop.friday) {
			   ^
Main.java:122: error: illegal start of type
			if (shop.saturday) {
			   ^
Main.java:128: error: illegal start of type
			if (shop.sunday) {
			   ^
18 errors
stdout
Standard output is empty