shouryaj98 / Hotel-Management-Project-Java

It is a Hotel Management tool which can be used to manage activites like storing customer details, booking rooms of four different types, ordering food for particular rooms, unbooking rooms and showing the bill.
MIT License
346 stars 435 forks source link

Solid Principles compliance #4

Open dsantistevan opened 4 years ago

dsantistevan commented 4 years ago

3 The class Guest that has the variables held before by a room has been added to the project, also some changes were made to the Project.java class in order to comply with it. The class Guest has the following structure:

public class Guest implements Serializable{
    String name;
    String contact;
    String gender;

The attributes kept default access so the program can access them like before.

5 The fixes to the OCP principle were made by creating an abstract class Room that has an ArrayList of Guest objects and can add up to maxCapacity int variable amount of elements. SingleRoom has a maxCapacity of 1 and DoubleRoom a max capacity of 2. Also, the code was adjusted to comply with these changes.

The class Room has the following structure and method addGuest():

abstract class Room implements Serializable{
    ArrayList<Guest> guests=new ArrayList<>();
    int maxCapacity;
    ArrayList<Food> food =new ArrayList<>();

    void addGuest(Guest g) {
        if(g!=null && guests.size()<maxCapacity)
            guests.add(g);
        else if(g!=null)
            throw new NotAvailable();

    }
}
dsantistevan commented 4 years ago

6 Added classes FoodItem and FoodList, in order to comply with Open Closed Principle of SOLID design.

Now to extend the amount of items it's just needed to add them at the initiateFood method, it could also read from a file, but now it is only necessary to modify initiateFood.

        static void initiateFood() {
        foodList.add(new FoodItem(50,1));
        foodList.add(new FoodItem(60,2));
        foodList.add(new FoodItem(70,3));
        foodList.add(new FoodItem(30,4));
    }
PrajaktaBendreBito commented 1 week ago

Code Review Agent Run #2aa38a

High-level Feedback

The code demonstrates commendable efforts in restructuring and improving the hotel management system. Key strengths include the introduction of abstraction and better organization of classes. However, there are critical areas requiring attention, particularly in resource management and exception handling. Prioritize addressing the potential resource leak in file operations and correct the serialization issue to prevent performance degradation. Additionally, optimize the addGuest method and reconsider the exception hierarchy for NotAvailable. Implementing these changes will significantly enhance the system's robustness and efficiency. Keep up the good work in refining the architecture, and consider adding unit tests to ensure the reliability of these improvements.

Actionable Issues

:page_facing_up: Project.java
Issues: Total - 4, High importance - 4
Line 52-52 πŸ”΄ High importance - 1   
Line 74-74 πŸ”΄ High importance - 1   
Line 503-503 πŸ”΄ High importance - 1   
Line 525-525 πŸ”΄ High importance - 1   
:page_facing_up: Guest.java
Issues: Total - 1, High importance - 1
Line 11-11 πŸ”΄ High importance - 1   
AI Code Review powered by Bito Logo **Note:** Introducing Bito’s AI Code Review Agent in your IDE. Get on-demand feedback with context as you code in JetBrains or Visual Studio Code. Catch issues early, improve code quality, ship faster β€” all before you get to PR. [Learn more](https://bit.ly/3ANCBwR)