房屋出租信息管理

  • e2_725097
    了解作者
  • 24.5KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-15 17:30
    上传日期
创建以下各类:①出租人信息类(Renter),②房屋信息类(RoomInfo),③承租客户类(Customer),。使用ArrayList列表存放以上各类数据。为了防止程序退出后以上信息不会丢失,使用3个文件分别存储以上各类的数据。要求管理程序实现以下功能: ⑴ 实现出租人信息的添加、修改、删除。 ⑵ 实现房屋信息的添加、修改、删除。 ⑶ 实现承租人信息的添加、修改和删除。 ⑷ 实现查询指定出租人的房屋出租信息。 ⑸ 实现查询指定房屋的出租信息。 ⑹ 实现查询指定承租人的房屋承租信息。 以上操作需保证各类数据的一致性。
房屋管理系统.rar
  • 课程设计代码
  • AddRoom120.java
    4.4KB
  • MidifiedRoom120.java
    4.4KB
  • RenterInfo120.java
    2.7KB
  • CustomerInfo120.java
    2.7KB
  • Renter120.java
    6.4KB
  • RoomInfo120.java
    2.5KB
  • FindRoomWrite120.java
    7.1KB
  • FindCustomer120.java
    1.4KB
  • FindRoom120.java
    1.4KB
  • DeleteRoom120.java
    1.5KB
  • DeleteCustomer120.java
    1.3KB
  • KeChengSheJi120.java
    2.3KB
  • AddRenter120.java
    2.6KB
  • DeleteRenter120.java
    1.5KB
  • MidifiedCustomer120.java
    3.7KB
  • FindRenter120.java
    1.4KB
  • Room120.java
    9.1KB
  • Customer120.java
    8.1KB
  • FindCustomerWrite120.java
    6.4KB
  • AddCustomer120.java
    3.7KB
  • FindRenterWrite120.java
    5.1KB
  • MidifiedRenter120.java
    2.6KB
内容介绍
import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.ArrayList; import java.util.Scanner; //房屋信息类 @SuppressWarnings("serial") public class Room120 implements java.io.Serializable{ private String RoomID; //房屋ID private String RenterID; //出租人ID private String RoomType; //房屋类型 private String Location; //房屋位置 private double Floor; //房屋楼层 private double Number; //房间号 private double RatingNum; //额定人数 private double TrueNum; //实住人数 private double Area; //面积 private boolean IsAircondition; //是否有空调 private boolean IsTelephone; //是否有电话 private boolean IsTV; //是否有电视 private boolean IsInternet; //是否有宽带 private boolean IsSeparateWashroom; //是否有独立卫生间 private boolean IsSeparateKitchen; //是否有独立厨房 private String Remark; //备注 private int number; public Room120(){ } public Room120(String RoomID,String RenterID,String RoomType,String Location,double Floor,double Number,double RatingNum,double TrueNum,double Area,boolean IsAircondition,boolean IsTelephone,boolean IsTV,boolean IsInternet,boolean IsSeparateWashroom,boolean IsSeparateKitchen,String Remark){ this.RoomID=RoomID; this.RenterID=RenterID; this.RoomType=RoomType; this.Location=Location; this.Floor=Floor; this.Number=Number; this.RatingNum=RatingNum; this.TrueNum=TrueNum; this.Area=Area; this.IsAircondition=IsAircondition; this.IsTelephone=IsTelephone; this.IsTV=IsTV; this.IsInternet=IsInternet; this.IsSeparateWashroom=IsSeparateWashroom; this.IsSeparateKitchen=IsSeparateKitchen; this.Remark=Remark; } public void setRoomInfo120(Room120 room120){ this.RoomID=room120.RoomID; this.RenterID=room120.RenterID; this.RoomType=room120.RoomType; this.Location=room120.Location; this.Floor=room120.Floor; this.Number=room120.Number; this.RatingNum=room120.RatingNum; this.TrueNum=room120.TrueNum; this.Area=room120.Area; this.IsAircondition=room120.IsAircondition; this.IsTelephone=room120.IsTelephone; this.IsTV=room120.IsTV; this.IsInternet=room120.IsInternet; this.IsSeparateWashroom=room120.IsSeparateWashroom; this.IsSeparateKitchen=room120.IsSeparateKitchen; this.Remark=room120.Remark; } //查询房屋信息 public Room120 FindRoom120(String a) throws ClassNotFoundException,IOException{ java.io.File file = new java.io.File("numberRoom120.txt"); Scanner number = new Scanner(file); this.number=number.nextInt(); number.close(); ArrayList<Room120> list = new ArrayList<>(); try{ ObjectInputStream input = new ObjectInputStream(new FileInputStream("Room120.dat")); for(int n=0;n<this.number;n++){ list.add((Room120) input.readObject()); } input.close(); } catch(Exception ex){ System.out.println("ok"); } int k=-1; for(int index=0;index<list.size();index++){ if(list.get(index).getRoomID().equals(a)){ k=index; break; } } if(k==-1) return null; else return list.get(k); } //添加房屋信息 public void AddRoom120(ArrayList<Room120> list) throws ClassNotFoundException,IOException{ java.io.File file = new java.io.File("numberRoom120.txt"); Scanner number = new Scanner(file); this.number=number.nextInt(); number.close(); ArrayList<Room120> list1 = new ArrayList<>(); if(this.number!=0){ try{ ObjectInputStream input = new ObjectInputStream(new FileInputStream("Room120.dat")); for(int n=0;n<this.number;n++){ list.add((Room120) input.readObject()); } input.close(); } catch(Exception ex){ } list1.addAll(list); } else list1.addAll(list); this.number=this.number+1; try{ ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream("Room120.dat")); for(int index=0;index<list1.size();index++){ output.writeObject(list1.get(index)); } output.close(); }catch(Exception ex){ } java.io.File file1 = new java.io.File("numberRoom120.txt"); java.io.PrintWriter output1=new java.io.PrintWriter(file1); output1.print(this.number); output1.close(); } //修改房屋信息 public void MidifiedRoom120(ArrayList<Room120> list)throws ClassNotFoundException,IOException{ java.io.File file = new java.io.File("numberRoom120.txt"); Scanner number = new Scanner(file); this.number=number.nextInt(); number.close(); ArrayList<Room120> list1 = new ArrayList<>(); try{ ObjectInputStream input = new ObjectInputStream(new FileInputStream("Room120.dat")); for(int n=0;n<this.number;n++){ list.add((Room120) input.readObject()); } input.close(); }catch(Exception ex){ } int k=-1; for(int index=0;index<list1.size();index++){ if(list1.get(index).getRoomID().equals(list.get(0).getRoomID())){ k=index; break; } } if(k!=-1) list1.remove(k); list1.addAll(list); try{ ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream("Room120.dat")); for(int index=0;index<list1.size();index++){ output.writeObject(list1.get(index)); } output.close(); }catch(Exception ex){ } } //删除房屋信息 public void DeleteRoom120(String a)throws ClassNotFoundException,IOException{ java.io.File file = new java.io.File("numberRoom120.txt"); Scanner number = new Scanner(file); this.number=number.nextInt(); number.close(); int k=-1; ArrayList<Room120> list = new ArrayList<>(); try{ ObjectInputStream input = new ObjectInputStream(new FileInputStream("Room120.dat")); for(int n=0;n<this.number;n++){ list.add((Room120) input.readObject()); } input.close(); } catch(Exception ex){ } for(int index=0;index<list.size();index++){ if(list.get(index).getRoomID().equals(a)){ k=index; break; } } if(k!=-1) list.remove(k); this.number=this.number-1; try{ ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream("Room120.dat")); for(int index=0;index<list.size();index++){ output.writeObject(list.get(index)); } output.close(); }catch(Exception ex){ } java.io.File file1 = new java.io.File("numberRoom120.txt"); java.io.PrintWriter output1=new java.io.PrintWriter(file1); output1.print(this.number); output1.close(); } public String getRoomID(){ return RoomID; } public void setRoomID(String roomID){ this.RoomID=roomID; } public String getRenterID(){ return RenterID; } public void setRenterID(String renterID){ this.RenterID=renterID; } public String getRoomType(){ return RoomType; } public void setRoomType(String roomType){ this.RoomType=roomType; } public String getLocation(){ return Location; } public void setLocation(String location){ this.Location=location; } public double getFloor(){ return Floor; } public void setFloor(double floor){ this.Floor=floor; } public double getNumber(){ return Number; } public void setNumber(double number){ this.Number=number; } public double getRatingNum(){ return RatingNum; } public void setRatingNum(double ratingNum){ this.RatingNum=ratingNum; } public double getTrueNum(
评论
    相关推荐