过滤列表以存储不同的组合

时间:2019-05-06 17:58:57

标签: java

我有可用的酒店客房列表

List <RoomInventory> inventoryList = new ArrayList<RoomInventory>();

列表中有不同类型的房间(双人间,家庭间,双床间,三人间) 每个都有价格,roomCode等。 每个房间可容纳最多人数 我需要显示7人聚会中最便宜的3个选项。 我的问题是如何为7人聚会找到并存储不同的房间组合?

这就是我所拥有的(创建了一系列不同的房间选项以显示给用户)

roomOptions roomOption1 = new roomOptions("family", 2);
roomOption1.setRoomType("family");
roomOption1.setNumberOfRooms(2);
roomOptions.add(roomOption1);

roomOptions roomOption2 = new roomOptions("Family room" + "Twin Triple", 2);
roomOption2.setRoomType("family + Twin Triple");
roomOption2.setNumberOfRooms(2);
roomOptions.add(roomOption2);

roomOptions roomOption3 = new roomOptions("Twin Room", 4);
roomOption3.setRoomType("Twin");
roomOption3.setNumberOfRooms(4);
roomOptions.add(roomOption3);

roomOptions roomOption4 = new roomOptions("Double Room" +  "Twin Room", 4);
roomOption4.setRoomType("Double + Twin Room");
roomOption4.setNumberOfRooms(4);
roomOptions.add(roomOption4);

roomOptions roomOption5 = new roomOptions("Family Room" + "Twin Room" + "Double" , 3);
roomOption5.setRoomType("Family Room + Double + Twin Room");
roomOption5.setNumberOfRooms(3);

是否有更动态的方式来找到适合7人聚会的不同房间组合?

0 个答案:

没有答案