封装HomeView类
import com.team1.util.ScannerUtil;
import java.sql.SQLOutput;
import java.util.Scanner;
public class HomePage {
public static void main(String[] args) throws Exception {
HomePage homePage = new HomePage();
homePage.loginView();
homePage.homeView();
}
private void homeView() {
System.out.println("欢迎登录商城,请选择业务:");
boolean flag = true;
System.out.println("1.购买商品 2.查看个人信息 3.查看购物车 4.付款 5.账户充值 6.退出商城");
while (true) {
String function = ScannerUtil.getInput();
switch (function) {
case ShopConstent.FUNCTION_SHOP:
Shop shop = new Shop();
shop.shopView();
break;
case ShopConstent.FUNCTION_PERSONAL:
User user = new User();
user.userView();
break;
case ShopConstent.FUNCTION_CART:
Cart cart = new Cart();
cart.getCartMessage();
break;
case ShopConstent.FUNCTION_PAYMENT:
Payment payment = new Payment();
payment.paymentView();
break;
case ShopConstent.FUNCTION_RECHARGE:
Recharge recharge = new Recharge();
recharge.rechargeView();
break;
}
}
}
//展示注册登录页面
public void loginView(){
boolean flag = true;
while (flag){
System.out.println("请选择功能:"+ShopConstent.USER_LOGIN+"登录 "+ShopConstent.USER_REGIST+"注册");
Scanner scanner = new Scanner(System.in);
String function = scanner.next();
//User user = new User();
switch (function){
case ShopConstent.USER_LOGIN:
flag = !ShopConstent.LOGIN_USER.login();
break;
case ShopConstent.USER_REGIST:
ShopConstent.LOGIN_USER.regist();
}
}
}
}