-
Notifications
You must be signed in to change notification settings - Fork 195
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
base: master
Are you sure you want to change the base?
Blob/kata/collection/start #52
Conversation
Kata/collections/start
There was a problem hiding this 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; | ||
} |
There was a problem hiding this comment.
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)); | ||
} |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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<>(); |
There was a problem hiding this comment.
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.
Exercise designed and implemented as per solution for the same