Skip to content

Blob/kata/collection/start#52

Open
pravyada wants to merge 14 commits intoserenity-dojo:masterfrom
pravyada:blob/kata/collection/start
Open

Blob/kata/collection/start#52
pravyada wants to merge 14 commits intoserenity-dojo:masterfrom
pravyada:blob/kata/collection/start

Conversation

@pravyada
Copy link
Copy Markdown

Exercise designed and implemented as per solution for the same

Copy link
Copy Markdown
Contributor

@wakaleo wakaleo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great progress Pravesh!

*/
public enum HotelAvailability {
Available,Full;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of an enum to make the code more readable.

{
CHECK_IN_STRATEGY .put(HotelAvailability.Available,new ConfirmBookingStrategy(petList));
CHECK_IN_STRATEGY .put(HotelAvailability.Full,new WaitingListStrategy(petsInWaitingList));
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff! This block could be static since the CHECK_IN_STRATEGY field is static.


public void checkOut(Pet pet){
petList.remove(pet);
if(!petsInWaitingList.isEmpty())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always use curly brackets with if statements - it's safer for code maintenance.

public class PetHotel {
public static final int MAX_SIZE = 20;
private Collection<Pet> petList = new TreeSet<>(comparing(Pet::getName));
private static Queue<Pet> petsInWaitingList = new LinkedList<>();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The waiting list should not be static, as it is associated with the hotel. In general, be very wary of using static fields anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants