问题标题 java简易租房管理系统 期望金额50金币 已托管0金币 提问人:任* 提问时间:2019-01-03
问题详情
特别要求
其他设置 期望完成时间:2019-01-10
管理员补充 收藏 我来回答
以下部分为回答内容,共1个回答
1楼

D{N}U[B{43XH8L`M[28@H7S.png

首先建一个包,共7部分代码,结果图先放一下79@D@L9CFEDUUSM9B0K1%]I.png

下面是代码,复制粘贴就可以了,第一部分

package building;


import java.util.Scanner;


public class BuildingMain {

public static void main(String[] args) {

System.out.println("****************************************");

System.out.println("*                                      *");

System.out.println("*                                      *");

System.out.println("*                                      *");

System.out.println("*                                      *");

System.out.println("*                 java大厦                           *");

System.out.println("*                                      *");

System.out.println("*                                      *");

System.out.println("*                                      *");

System.out.println("*                                      *");

System.out.println("****************************************");

PayManage payManage = new PayManage();

RegisterManage register = new RegisterManage();

RoomManage manage = new RoomManage();

Scanner scanner = new Scanner(System.in);

while (true) {

System.out.println("1.进门登记");

System.out.println("2.租房");

System.out.println("3.撤租");

System.out.println("4.看房");

System.out.println("5.缴费");

System.out.println("6.设置缴费金额");

System.out.println("7.进门记录");

System.out.println("8.按月份查看缴费");

System.out.println("9.按房间号看缴费");

System.out.println("0.退出");

int num = scanner.nextInt();

switch (num) {

case 1: {

register.add();

break;

}

case 2: {


manage.rentRoom();

break;

}

case 3: {

manage.recede();

break;

}

case 4: {

manage.examineRoom();

break;

}

case 5: {

payManage.paymanage();

break;

}

case 6: {

payManage.setpayment();

break;

}

case 7:{

register.query();

break;

}

case 8:

{

System.out.println("请输入月份:");

int month = scanner.nextInt();

payManage.MonthserchPay(month);

break;

}

case 9:

{

System.out.println("请输入房号:");

int roomNum = scanner.nextInt();

payManage.NumserchPay(roomNum);

break;

}

case 0:

System.exit(0);

}

}

}

}

        第二部分

package building;


import java.util.ArrayList;

import java.util.Date;

import java.util.Scanner;


public class PayManage {

ArrayList<PaymentList> paymentLists = new ArrayList<PaymentList>();

Scanner scanner = new Scanner(System.in);


// 缴费

public void paymanage() {

System.out.println("请输入房间号:");

int num = scanner.nextInt();

int result = checkArrears(num);

if (result == 0) {

System.out.println("您没有欠费记录!");

} else {

System.out.println("您有以下费用没有缴纳:");

for (PaymentList paymentList : paymentLists) {

if (paymentList.getRoomNum() == num && paymentList.getArrears() != 0)

System.out.println(paymentList);

}

while (true) {

System.out.println("1.水费");

System.out.println("2.电费");

System.out.println("3物业费");

int select = scanner.nextInt();

System.out.println("请选择:");

switch (select) {

case 1: {

System.out.println("请输入月份:");

int month = scanner.nextInt();

payMoney(num, select, month);

break;

}

case 2: {

System.out.println("请输入月份:");

int month = scanner.nextInt();

payMoney(num, select, month);


break;

}

case 3: {

System.out.println("请输入月份:");

int month = scanner.nextInt();

payMoney(num, select, month);

break;

}

}

System.out.println("是否退出(y/n)");

if ("y".equalsIgnoreCase(scanner.next()))

break;

}

}

}


public void payMoney(int num, int select, int month) {

for (PaymentList paymentList : paymentLists) {

if (paymentList.getRoomNum() == num && paymentList.getType() == select && paymentList.getMonth() == month

&& paymentList.getArrears() != 0) {

System.out.println("应交电费:" + paymentList.getArrears());

int money = scanner.nextInt();

paymentList.setPay(money);

paymentList.setArrears(0);

;

paymentList.setDate(new Date());

}

}

}


// 设置缴费

public void setpayment() {

System.out.println("请输入月份:");

int month = scanner.nextInt();

System.out.println("请输入房间号:");

int roomNum = scanner.nextInt();

System.out.println("请输入水费:");

int water = scanner.nextInt();

System.out.println("请输入电费:");

int power = scanner.nextInt();

System.out.println("请输入物业费:");

int Property = scanner.nextInt();

PaymentList list1 = new PaymentList(month, roomNum, 1, water);

PaymentList list2 = new PaymentList(month, roomNum, 2, power);

PaymentList list3 = new PaymentList(month, roomNum, 3, Property);

paymentLists.add(list1);

paymentLists.add(list2);

paymentLists.add(list3);


}


private int checkArrears(int num) {

for (PaymentList paymentList : paymentLists) {

if (paymentList.getRoomNum() == num && paymentList.getArrears() != 0)

return 1;

}

return 0;

}


// 按照月份查看收费记录

public void MonthserchPay(int month) {

for (PaymentList paymentList : paymentLists) {

if (paymentList.getMonth() == month) {

System.out.println(paymentList);

}


}

}


public void NumserchPay(int roomNum) {

for (PaymentList paymentList : paymentLists) {

if (paymentList.getRoomNum() == roomNum) {

System.out.println(paymentList);

}


}

}

}

           第三部分

package building;


import java.text.SimpleDateFormat;

import java.util.Calendar;

import java.util.Date;


public class PaymentList {

private int roomNum;

private Date date;

private int type;

private int month;

private int Arrears;

private int Pay;

public PaymentList(int month,int roomNum,int type, int Arrears) {

super();

this.month = month;

this.roomNum = roomNum;

this.type = type;

this.Arrears = Arrears;

}



public int getRoomNum() {

...展开更多
......此处隐藏剩余部分6325字,需支付50金币方可查看...... 购买回答