Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blob/kata/collection/start #52

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

pravyada
Copy link

Exercise designed and implemented as per solution for the same

Copy link
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
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
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
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
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