初级系统全过程,笔记

初级系统全过程,笔记_第1张图片

package Houserent.view;

import Houserent.domain.House;
import Houserent.service.HouseService;
import Houserent.utils.Utils;

/**
 *显示界面
 * 2. 接收用户的输入
 *  3.调用HouseView完成对房屋信息的各种操作
  */
public class HouseView {

    private boolean loop = true;//控制显示菜单
    private char key = ' ';//接收用户选择
    private HouseService houseService = new HouseService(10);

//根据id修改信息
    public void update(){
        System.out.println("=======修改信息=======");
        System.out.println("请选择要修改的编号(-1退出)");
        int updateId = Utils.readInt();
        if (updateId == -1) {
            System.out.println("放弃修改");
            return;
        }

        //根据输入的id查找对象
        House house = houseService.findById(updateId);
        if (house == null){
            System.out.println("=======信息不存在");
            return;
        }

        System.out.println("姓名("+house.getName()+"): ");
        String name = Utils.readString(8,"");
        if(!"".equals(name)){
            house.setName(name);
        }
        System.out.println("电话("+house.getPhone()+"): ");
        String phone= Utils.readString(12,"");
        if(!"".equals(phone)){
            house.setPhone(phone);
        }
        System.out.println("地址("+house.getAddress()+"): ");
        String address= Utils.readString(15,"");
        if(!"".equals(address)){
            house.setAddress(address);
        }
        System.out.println("租金("+house.getRent()+"): ");
        int rent= Utils.readInt(-1);
        if(rent == -1){
            house.setRent(rent);
        }
        System.out.println("状态("+house.getState()+"): ");
        String state= Utils.readSt

你可能感兴趣的:(java,笔记,ide)