Commit 4422e3ca authored by Enrico Bollen's avatar Enrico Bollen 💬
Browse files

removes id based on array len

parent 1601a469
Pipeline #1804 failed with stages
in 58 seconds
......@@ -35,17 +35,10 @@ func (b *Building) New(openFrom string, openDuration string, workdays []string)
// AddRoom adds rooms to building.
// takes number and capacity
func (b *Building) AddRoom(roomNumber int, capacity int) (room *Room, err error) {
all := b.GetRooms()
var onlyRooms []*Room
for _, rooms := range all {
onlyRooms = append(onlyRooms, rooms)
}
id := len(all)
room, err = b.GetRoomByNo(roomNumber)
if err != nil {
room = &Room{ID: id, Number: roomNumber, Capacity: capacity}
room = &Room{Number: roomNumber, Capacity: capacity}
b.Rooms = append(b.Rooms, room)
err = nil
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment