DietExt

Extended Requirements

The application to manage a diet by means of nutritional values computation has been extended to provide services for ordering and delivering food (takeaway).

The application allow creating restaurants, registering users, making orders, etc.

All the classes must be in the package "diet".

R5 - Restaurant

The Restaurant can be created providing a name and a reference to a Food object so that all the ingredients, products, and recipes can be defined for each of the restaurants individually.

A restaurant can be identified by its name. Through the method setHours() working hours can be set for the restaurant. The methods accepts an array of strings (even number of elements) in the format "HH:MM", so that the closing hours follow the opening hours (e.g., for a restaurant opened from 8:15 until 14:00 and from 19:00 until 00:00, arguments would be "08:15", "14:00", "19:00", "00:00"). Getter getName() returns a restaurant's name. Restaurant offer different menus, and they can be created through the method createMenu() having as argument menu's name and returning Menu object.

Restaurants can be registered with the system using the method addRestaurant() of the facade class Takeaway. The method restaurants() returns the names of the registered restaurants.

R6 - Users

A user is defined by providing its first name, last name, email and phone number to the method registerUser() that returns a User object. Getters are provided for all of the fields (getFirstName(), getLastName(), getEmail(), getPhone()), while setters are provided for the email and phone number only (setEmail(), setPhone). The string representation of a User object returns the last name separated by a space and followed by the first name.

To retrieve information about the users we can use the method users() of class Takeaway that returns a collection of users sorted first by their last name and then by first name.

R7 - Orders

A registered user can make an order at one of the available restaurants. For such purpose method createOrder() accepts as arguments the User object making the order, restaurant's name (String) and the desired delivery time (hour and minute as integers). Furthermore, if for the given order delivery time is outside of the working hours for the restaurant, delivery time is set to the first successive opening hour (e.g., making an order for a restaurant having working hours from 8:15 until 14:00 and from 19:00 until 00:00, and asking for a delivery at 15:30, would result in having the delivery time set for 19:00).

An order can have three statuses: ORDERED, READY, DELIVERED accessible through setter and getter setStatus() and getStatus() (ORDERED by default). Furthermore, payment type for an order can be: PAID, CASH, CARD, accessible through setter and getter setPaymentMethod() and getPaymentMethod() (CASH by default).

Menus can be added to an order by calling the method addMenus and specifying the menu name (String) and the quantity (integer).

When an order is printed, it should be formatted as:

"RESTAURANT_NAME, USER_FIRST_NAME USER_LAST_NAME : DELIVERY(HH:MM):
	MENU_NAME_1->MENU_QUANTITY_1
	...
	MENU_NAME_k->MENU_QUANTITY_k
"

The menus are sorted by menu name and are printed on different lines preceded by a tab ('\t').

R8 - Information

To retrieve some information about the restaurants we can use the method openedRestaurants() that has one string argument in format "HH:MM" and returns a collection of Restaurant that are opened at the given time, sorted by their name alphabetically. A restaurant is opened if there is at least one working hour segment such that the defined time is inside the range [open, close).

Information about certain orders for a restaurant can be obtained through method ordersWithStatus() of the class Restaurant. Such method returns a String obtained by concatenating all orders satisfying the criteria.

Napoli, Judi Dench : (19:00):
	M6->1
Napoli, Ralph Fiennes : (19:00):
	M1->2
	M6->1

The list is sorted by name of restaurant, name of the user, and delivery time.