From e97035ca2ef17f5c0f906ea23afa30fd6bcbe7f7 Mon Sep 17 00:00:00 2001 From: 100yo Date: Sat, 16 Nov 2024 19:48:57 +0200 Subject: [PATCH] Add details to Homework 01 assignment --- homeworks/01-glovo/README.md | 225 +++++++++++++++++++++-------------- homeworks/README.md | 5 + 2 files changed, 138 insertions(+), 92 deletions(-) create mode 100644 homeworks/README.md diff --git a/homeworks/01-glovo/README.md b/homeworks/01-glovo/README.md index 1845dd94..145c5212 100644 --- a/homeworks/01-glovo/README.md +++ b/homeworks/01-glovo/README.md @@ -2,24 +2,22 @@ ## Glovo 🚚 -`ΠšΡ€Π°Π΅Π½ срок: [30.11.2024 23:59:59]` +`ΠšΡ€Π°Π΅Π½ срок: 30.11.2024 23:59` ### ОписаниС Π½Π° Π·Π°Π΄Π°Ρ‡Π°Ρ‚Π° ИмамС привилСгията Π΄Π° ΠΆΠΈΠ²Π΅Π΅ΠΌ Π² свят, Π² ΠΊΠΎΠΉΡ‚ΠΎ Ρ…Ρ€Π°Π½Π° ΠΈ всякакви ΠΏΠΎΠΊΡƒΠΏΠΊΠΈ ΠΎΡ‚ ΠΌΠ°Π³Π°Π·ΠΈΠ½Π° Π΄ΠΎΠ»ΠΈΡ‚Π°Ρ‚ ΠΏΡ€ΠΈ вас с Π΅Π΄ΠΈΠ½ ΠΊΠ»ΠΈΠΊ. Π‘Π΅Π³Π° си прСдставСтС, Ρ‡Π΅ Π²ΠΈΠ΅ стС ΠΌΠ°Π³ΡŒΠΎΡΠ½ΠΈΡ†ΠΈΡ‚Π΅ Π·Π°Π΄ Ρ‚Π°Π·ΠΈ магия! Π©Π΅ Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΈΡ‚Π΅ ΠΏΡ€ΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π·Π° доставка, ΠΊΠΎΠ΅Ρ‚ΠΎ Π½Π΅ само слСди къдС Π΅ Π²Π°ΡˆΠΈΡΡ‚ Π±ΡƒΡ€Π³Π΅Ρ€ ΠΈΠ»ΠΈ ΠΏΠΈΡ†Π° Π² ΠΌΠΎΠΌΠ΅Π½Ρ‚Π°, Π½ΠΎ ΠΈ Π³Π°Ρ€Π°Π½Ρ‚ΠΈΡ€Π°, Ρ‡Π΅ Ρ‚Π΅ Ρ‰Π΅ пристигнат Ρ‚ΠΎΠΏΠ»ΠΈ, вкусни ΠΈ Π½Π°Π²Ρ€Π΅ΠΌΠ΅ πŸ•πŸ₯‘, прСнасяйки щастиС Π΄ΠΈΡ€Π΅ΠΊΡ‚Π½ΠΎ Π΄ΠΎ Π²Ρ€Π°Ρ‚Π°Ρ‚Π° Π½Π° Ρ…ΠΎΡ€Π°Ρ‚Π°! πŸš€πŸŸ #### Π‘ΡŠΡ€Π· ΠΏΠΎΠ³Π»Π΅Π΄ Π½Π°Π΄ Π·Π°Π΄Π°Ρ‡ΠΈΡ‚Π΅ + 1. Π”Π°Π΄Π΅Π½ΠΈ са Π΄Π²Π° интСрфСйса, ΠΊΠ°ΠΊΡ‚ΠΎ ΠΈ няколко ΠΏΠΎΠΌΠΎΡ‰Π½ΠΈ класа. Π˜ΠΌΠΏΠ»Π΅ΠΌΠ΅Π½Ρ‚ΠΈΡ€Π°ΠΉΡ‚Π΅ интСрфСйситС. НС промСняйтС сигнатуритС Π½Π° Π΄Π°Π΄Π΅Π½ΠΈΡ‚Π΅ ΠΌΠ΅Ρ‚ΠΎΠ΄ΠΈ, ΠΊΠ°ΠΊΡ‚ΠΎ ΠΈ всички конструктури, Π΄Π°Π΄Π΅Π½ΠΈ Π² условиСто. МоТС Π΄Π° добавятС ΠΎΡ‰Π΅ класовС, Π°ΠΊΠΎ смСтнСтС Π·Π° Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ. 2. Π”ΠΎΠ±Π°Π²Π΅Ρ‚Π΅ **ΠΏΠΎΠ½Π΅ Π΄Π²Π°** ***ваши***, Ρ‚.Π΅. Π½Π΅ част ΠΎΡ‚ Java JDK, Runtime Exceptions, ΠΊΠΎΠΈΡ‚ΠΎ Π΄Π° сС Ρ…Π²ΡŠΡ€Π»ΡΡ‚ Π² някои ΠΎΡ‚ ΠΌΠ΅Ρ‚ΠΎΠ΄ΠΈΡ‚Π΅ Π²ΠΈ. КоС ΠΏΠΎΠ²Π΅Π΄Π΅Π½ΠΈΠ΅ сС ΠΏΡ€ΠΈΠ΅ΠΌΠ° Π·Π° бъг Π½Π° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠ°Ρ‚Π° Ρ‚ΠΎΠ·ΠΈ ΠΏΡŠΡ‚ опрСдСлятС Π²ΠΈΠ΅. 3. Π”ΠΎΠ±Π°Π²Π΅Ρ‚Π΅ Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΈΡ‚Π΅ Π²Π°Π»ΠΈΠ΄Π°Ρ†ΠΈΠΈ Π·Π° Π²Π°Π»ΠΈΠ΄Π½ΠΈ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΈ, ΠΏΠΎΠ΄Π°Π΄Π΅Π½ΠΈ Π½Π° ΠΌΠ΅Ρ‚ΠΎΠ΄ΠΈΡ‚Π΅, Π΄Π΅Ρ„ΠΈΠ½ΠΈΡ€Π°Π½ΠΈ Π² интСрфСйса. 4. Π’ΠΈΠ΅ ΠΈΠ·Π±ΠΈΡ€Π°Ρ‚Π΅ ΠΊΠ°ΠΊΠ²ΠΈ Π°Π»Π³ΠΎΡ€ΠΈΡ‚ΠΌΠΈ Π΄Π° ΠΈΠ·ΠΏΠΎΠ»Π·Π²Π°Ρ‚Π΅. Ако ΠΈΠ·ΠΏΠΎΠ»Π·Π²Π°Ρ‚Π΅ ΠΏΠΎ-Π΅Ρ„Π΅ΠΊΡ‚ΠΈΠ²Π΅Π½, Π±ΠΈΡ…Ρ‚Π΅ ΠΏΠΎΠ»ΡƒΡ‡ΠΈΠ»ΠΈ бонус Ρ‚ΠΎΡ‡ΠΊΠΈ, Π½ΠΎ с Ρ‚Ρ€ΠΈΠ²ΠΈΠ°Π»Π΅Π½ ΠΏΠΎΠ΄Ρ…ΠΎΠ΄, стига Π΄Π° Ρ€Π°Π±ΠΎΡ‚ΠΈ ΠΏΡ€Π°Π²ΠΈΠ»Π½ΠΎ, със сигурност няма Π΄Π° Π²ΠΈ Π±ΡŠΠ΄Π°Ρ‚ Π²Π·Π΅Ρ‚ΠΈ Ρ‚Π°ΠΊΠΈΠ²Π°. -⚠️***Π’ΠΠ–ΠΠž Π£Π’ΠžΠ§ΠΠ•ΠΠ˜Π•:*** - -**РСшСния, ΠΈΠ·ΠΏΠΎΠ»Π·Π²Π°Ρ‰ΠΈ [Java Stream API](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/stream/package-summary.html), [lambdas](https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html), ΠΈ всичко останало, ΠΊΠΎΠ΅Ρ‚ΠΎ Π½Π΅ Π΅ ΠΏΠΎΠΊΡ€ΠΈΡ‚ΠΎ Π΄ΠΎ ΠΌΠΎΠΌΠ΅Π½Ρ‚Π°, няма Π΄Π° сС ΠΏΡ€ΠΈΠ΅ΠΌΠ°Ρ‚ Π·Π° Ρ‚ΠΎΠ²Π° домашно.** - ### GlovoApi -Π’ ΠΏΠ°ΠΊΠ΅Ρ‚Π° `bg.sofia.uni.fmi.mjt.glovo` ΡΡŠΠ·Π΄Π°ΠΉΡ‚Π΅ интСрфСйса `GlovoApi`. ΠšΠ°ΠΊΡ‚ΠΎ Π²Π΅Ρ‡Π΅ стС свикнали - ΠΊΠ°ΠΊΠ²ΠΎ сС ΠΎΡ‡Π°ΠΊΠ²Π° Π΄Π° бъдС ΠΏΠΎΠ²Π΅Π΄Π΅Π½ΠΈΠ΅Ρ‚ΠΎ Π½Π° Π½Π΅Π³ΠΎΠ²ΠΈΡ‚Π΅ ΠΈΠΌΠΏΠ»Π΅ΠΌΠ΅Π½Ρ‚Π°Ρ‚ΠΎΡ€ΠΈ, Π΅ описано Π² java docs Π½Π°Π΄ всСки ΠΌΠ΅Ρ‚ΠΎΠ΄: + +Π’ ΠΏΠ°ΠΊΠ΅Ρ‚Π° `bg.sofia.uni.fmi.mjt.glovo` ΡΡŠΠ·Π΄Π°ΠΉΡ‚Π΅ интСрфСйса `GlovoApi`. ΠšΠ°ΠΊΡ‚ΠΎ Π²Π΅Ρ‡Π΅ стС свикнали - ΠΊΠ°ΠΊΠ²ΠΎ сС ΠΎΡ‡Π°ΠΊΠ²Π° Π΄Π° бъдС ΠΏΠΎΠ²Π΅Π΄Π΅Π½ΠΈΠ΅Ρ‚ΠΎ Π½Π° Π½Π΅Π³ΠΎΠ²ΠΈΡ‚Π΅ ΠΈΠΌΠΏΠ»Π΅ΠΌΠ΅Π½Ρ‚Π°Ρ‚ΠΎΡ€ΠΈ, Π΅ описано Π² javadocs Π½Π°Π΄ всСки ΠΌΠ΅Ρ‚ΠΎΠ΄: ```java package bg.sofia.uni.fmi.mjt.glovo; @@ -30,68 +28,77 @@ import bg.sofia.uni.fmi.mjt.glovo.exception.NoAvailableDeliveryGuyException; public interface GlovoApi { - /** - * Returns the cheapest delivery option for a specified food item from a restaurant to a client location. - * - * @param client The delivery destination, represented by a MapEntity. - * @param restaurant The location of the restaurant from which the food item is sourced, represented by a MapEntity. - * @param foodItem The name of the food item to be delivered. - * @return A Delivery object representing the cheapest available delivery option within the specified constraints. - * @throws InvalidOrderException If there is no client or restaurant at the specified location on the map, - * * or if the location is outside the map's defined boundaries. - * @throws NoAvailableDeliveryGuyException If no delivery guys are available to complete the delivery. - */ - Delivery getCheapestDelivery(MapEntity client, MapEntity restaurant, String foodItem) - throws NoAvailableDeliveryGuyException; - - /** - * Returns the fastest delivery option for a specified food item from a restaurant to a client location. - * - * @param client The delivery destination, represented by a MapEntity. - * @param restaurant The location of the restaurant from which the food item is sourced, represented by a MapEntity. - * @param foodItem The name of the food item to be delivered. - * @return A Delivery object representing the fastest available delivery option within the specified constraints. - * @throws InvalidOrderException If there is no client or restaurant at the specified location on the map, - * * or if the location is outside the map's defined boundaries. - * @throws NoAvailableDeliveryGuyException If no delivery guys are available to complete the delivery. - */ - Delivery getFastestDelivery(MapEntity client, MapEntity restaurant, String foodItem) - throws NoAvailableDeliveryGuyException; - - /** - * Returns the fastest delivery option under a specified price for a given food item from a restaurant to a client location. - * - * @param client The delivery destination, represented by a MapEntity. - * @param restaurant The location of the restaurant from which the food item is sourced, represented by a MapEntity. - * @param foodItem The name of the food item to be delivered. - * @param maxPrice The maximum price the client is willing to pay for the delivery. - * @return A Delivery object representing the fastest available delivery option under the specified price limit. - * @throws InvalidOrderException If there is no client or restaurant at the specified location on the map, - * * * or if the location is outside the map's defined boundaries. - * @throws NoAvailableDeliveryGuyException If no delivery guys are available to complete the delivery. - */ - Delivery getFastestDeliveryUnderPrice(MapEntity client, MapEntity restaurant, String foodItem, double maxPrice) - throws NoAvailableDeliveryGuyException; - - /** - * Returns the cheapest delivery option within a specified time limit for a given food item from a restaurant to a client location. - * - * @param client The delivery destination, represented by a MapEntity. - * @param restaurant The location of the restaurant from which the food item is sourced, represented by a MapEntity. - * @param foodItem The name of the food item to be delivered. - * @param maxTime The maximum allowable delivery time in minutes. - * @return A Delivery object representing the cheapest available delivery option within the specified time limit. - * @throws InvalidOrderException If there is no client or restaurant at the specified location on the map, - * * or if the location is outside the map's defined boundaries. - * @throws NoAvailableDeliveryGuyException If no delivery guys are available to complete the delivery. - */ - Delivery getCheapestDeliveryWithinTimeLimit(MapEntity client, MapEntity restaurant, String foodItem, int maxTime) - throws NoAvailableDeliveryGuyException; + /** + * Returns the cheapest delivery option for a specified food item from a restaurant to a client location. + * + * @param client The delivery destination, represented by a MapEntity. + * @param restaurant The location of the restaurant from which the food item is sourced, + * represented by a MapEntity. + * @param foodItem The name of the food item to be delivered. + * @return A Delivery object representing the cheapest available delivery option within the specified constraints. + * @throws InvalidOrderException If there is no client or restaurant at the specified location on the map, + * or if the location is outside the map's defined boundaries. + * @throws NoAvailableDeliveryGuyException If no delivery guys are available to complete the delivery. + */ + Delivery getCheapestDelivery(MapEntity client, MapEntity restaurant, String foodItem) + throws NoAvailableDeliveryGuyException; + + /** + * Returns the fastest delivery option for a specified food item from a restaurant to a + * client location. + * + * @param client The delivery destination, represented by a MapEntity. + * @param restaurant The location of the restaurant from which the food item is sourced, + * represented by a MapEntity. + * @param foodItem The name of the food item to be delivered. + * @return A Delivery object representing the fastest available delivery option within the specified + * constraints. + * @throws InvalidOrderException If there is no client or restaurant at the specified location on the map, + * or if the location is outside the map's defined boundaries. + * @throws NoAvailableDeliveryGuyException If no delivery guys are available to complete the delivery. + */ + Delivery getFastestDelivery(MapEntity client, MapEntity restaurant, String foodItem) + throws NoAvailableDeliveryGuyException; + + /** + * Returns the fastest delivery option under a specified price for a given food item from a restaurant + * to a client location. + * + * @param client The delivery destination, represented by a MapEntity. + * @param restaurant The location of the restaurant from which the food item is sourced, + * represented by a MapEntity. + * @param foodItem The name of the food item to be delivered. + * @param maxPrice The maximum price the client is willing to pay for the delivery. + * @return A Delivery object representing the fastest available delivery option under the specified price limit. + * @throws InvalidOrderException If there is no client or restaurant at the specified location on the map, + * or if the location is outside the map's defined boundaries. + * @throws NoAvailableDeliveryGuyException If no delivery guys are available to complete the delivery. + */ + Delivery getFastestDeliveryUnderPrice(MapEntity client, MapEntity restaurant, String foodItem, double maxPrice) + throws NoAvailableDeliveryGuyException; + + /** + * Returns the cheapest delivery option within a specified time limit for a given food item from a restaurant + * to a client location. + * + * @param client The delivery destination, represented by a MapEntity. + * @param restaurant The location of the restaurant from which the food item is sourced, + * represented by a MapEntity. + * @param foodItem The name of the food item to be delivered. + * @param maxTime The maximum allowable delivery time in minutes. + * @return A Delivery object representing the cheapest available delivery option within the specified time limit. + * @throws InvalidOrderException If there is no client or restaurant at the specified location on the map, + * or if the location is outside the map's defined boundaries. + * @throws NoAvailableDeliveryGuyException If no delivery guys are available to complete the delivery. + */ + Delivery getCheapestDeliveryWithinTimeLimit(MapEntity client, MapEntity restaurant, String foodItem, int maxTime) + throws NoAvailableDeliveryGuyException; } ``` ### ControlCenterApi + Π’ ΠΏΠ°ΠΊΠ΅Ρ‚Π° `bg.sofia.uni.fmi.mjt.glovo.controlcenter` ΡΡŠΠ·Π΄Π°ΠΉΡ‚Π΅ интСрфСйса `ControlCenterApi` ```java @@ -104,33 +111,37 @@ import bg.sofia.uni.fmi.mjt.glovo.delivery.ShippingMethod; public interface ControlCenterApi { - /** - * Finds the optimal delivery person for a given delivery task. The method - * selects the best delivery option based on the provided cost and time constraints. - * If no valid delivery path exists, it returns null. - * - * @param restaurantLocation The location of the restaurant to start the delivery from. - * @param clientLocation The location of the client receiving the delivery. - * @param maxPrice The maximum price allowed for the delivery. Use -1 for no cost constraint. - * @param maxTime The maximum time allowed for the delivery. Use -1 for no time constraint. - * @param shippingMethod The method for shipping the delivery. - * @return A DeliveryInfo object containing the optimal delivery guy, the total cost, - * the total time, and the delivery type. Returns null if no valid path is found. - */ - DeliveryInfo findOptimalDeliveryGuy(Location restaurantLocation, Location clientLocation, - double maxPrice, int maxTime, ShippingMethod shippingMethod); - - /** - * Returns the map - * @return A MapEntity[][] containing the map - */ - MapEntity[][] getLayout(); + /** + * Finds the optimal delivery person for a given delivery task. The method + * selects the best delivery option based on the provided cost and time constraints. + * If no valid delivery path exists, it returns null. + * + * @param restaurantLocation The location of the restaurant to start the delivery from. + * @param clientLocation The location of the client receiving the delivery. + * @param maxPrice The maximum price allowed for the delivery. Use -1 for no cost constraint. + * @param maxTime The maximum time allowed for the delivery. Use -1 for no time constraint. + * @param shippingMethod The method for shipping the delivery. + * @return A DeliveryInfo object containing the optimal delivery guy, the total cost, + * the total time, and the delivery type. Returns null if no valid path is found. + */ + DeliveryInfo findOptimalDeliveryGuy(Location restaurantLocation, Location clientLocation, + double maxPrice, int maxTime, ShippingMethod shippingMethod); + + /** + * Returns the map + * + * @return A MapEntity[][] containing the map + */ + MapEntity[][] getLayout(); + } ``` ### Π˜ΠΌΠΏΠ»Π΅ΠΌΠ΅Π½Ρ‚Π°Ρ†ΠΈΠΈ Π½Π° интСрфСйситС + Π˜ΠΌΠΏΠ»Π΅ΠΌΠ΅Π½Ρ‚Π°Ρ†ΠΈΡΡ‚Π° Π½Π° `GlovoApi` e `Glovo`. Π˜ΠΌΠΏΠ»Π΅ΠΌΠ΅Π½Ρ‚Π°Ρ†ΠΈΡΡ‚Π° Π½Π° `ControlCenterApi` Π΅ `ControlCenter`. -И Π΄Π²Π°Ρ‚Π° ΠΈΠΌΠΏΠ»Π΅ΠΌΠ΅Π½Ρ‚ΠΈΡ€Π°Ρ‰ΠΈ класа ΠΈΠΌΠ°Ρ‚ конструктори, ΠΊΠΎΠΈΡ‚ΠΎ ΠΏΡ€ΠΈΠ΅ΠΌΠ°Ρ‚ Π΅Π΄ΠΈΠ½ ΠΈ ΡΡŠΡ‰ΠΈ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚ΡŠΡ€ mapLayout, ΠΊΠΎΠΉΡ‚ΠΎ Ρ‰Π΅ обясним ΠΏΠΎ-Π½Π°Π΄ΠΎΠ»Ρƒ Π² Ρ‚Π°Π·ΠΈ сСкция: +И Π΄Π²Π°Ρ‚Π° ΠΈΠΌΠΏΠ»Π΅ΠΌΠ΅Π½Ρ‚ΠΈΡ€Π°Ρ‰ΠΈ класа ΠΈΠΌΠ°Ρ‚ конструктори, ΠΊΠΎΠΈΡ‚ΠΎ ΠΏΡ€ΠΈΠ΅ΠΌΠ°Ρ‚ Π΅Π΄ΠΈΠ½ ΠΈ ΡΡŠΡ‰ΠΈ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚ΡŠΡ€ `mapLayout`, ΠΊΠΎΠΉΡ‚ΠΎ Ρ‰Π΅ обясним ΠΏΠΎ-Π½Π°Π΄ΠΎΠ»Ρƒ Π² Ρ‚Π°Π·ΠΈ сСкция: + ```java public ControlCenter(char[][] mapLayout) {...} public Glovo(char[][] mapLayout) {...} @@ -138,6 +149,7 @@ public Glovo(char[][] mapLayout) {...} `mapLayout` Π΅ Π΄Π²ΡƒΠΌΠ΅Ρ€Π΅Π½ масив ΠΎΡ‚ символи, прСдставляващ ΠΊΠ°Ρ€Ρ‚Π°Ρ‚Π°, с която Ρ€Π°Π±ΠΎΡ‚ΠΈΠΌ Π² Ρ‚ΠΎΠ·ΠΈ ΠΌΠΎΠΌΠ΅Π½Ρ‚. На Ρ‚Π°Π·ΠΈ ΠΊΠ°Ρ€Ρ‚Π° са ΠΊΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚ΠΈΡ‚Π΅ Π½Π° всички рСсторанти, Π½Π° всички ΠΊΠ»ΠΈΠ΅Π½Ρ‚ΠΈ, ΠΊΠ°ΠΊΡ‚ΠΎ ΠΈ Π½Π° всички доставчици. ОсвСн Ρ‚ΠΎΠ²Π°, ΠΈΠΌΠ°ΠΌΠ΅ ΠΈ ΠΏΡŠΡ‚ΠΈΡ‰Π°Ρ‚Π° ΠΌΠ΅ΠΆΠ΄Ρƒ тях. Всяко Π΅Π΄Π½ΠΎ ΠΏΠΎΠ»Π΅ Π½Π° ΠΊΠ°Ρ€Ρ‚Π°Ρ‚Π° ΠΈΠΌΠ° спСциалСн символ. Π—Π½Π°Ρ‡Π΅Π½ΠΈΠ΅Ρ‚ΠΎ Π½Π° символитС Π΅ ΠΊΠ°ΠΊΡ‚ΠΎ слСдва: + * '#' = Wall * '.' = Road * 'R' = Restaurant @@ -145,9 +157,10 @@ public Glovo(char[][] mapLayout) {...} * 'A' = DeliveryGuy in a car * 'B' = DeliveryGuy on a Bike -ΠŸΠΎΡΠΎΠΊΠΈΡ‚Π΅ Π·Π° Π΄Π²ΠΈΠΆΠ΅Π½ΠΈΠ΅ ΠΏΠΎ ΠΊΠ°Ρ€Ρ‚Π°Ρ‚Π° са 4 - Π½Π°Π³ΠΎΡ€Π΅, Π½Π°Π΄ΠΎΠ»Ρƒ, наляво ΠΈ надясно. Π”ΠΎΡΡ‚Π°Π²Ρ‡ΠΈΠΊΡŠΡ‚ ΠΌΠΎΠΆΠ΅ Π΄Π° ΠΏΡ€Π΅ΠΌΠΈΠ½Π°Π²Π° ΠΏΡ€Π΅Π· всичко, Ρ€Π°Π·Π»ΠΈΡ‡Π½ΠΎ ΠΎΡ‚ стСна (Π²ΠΊΠ»ΡŽΡ‡ΠΈΡ‚Π΅Π»Π½ΠΎ ΠΈ Π΄Ρ€ΡƒΠ³ΠΈ доставчици). ΠŸΡ€ΠΈΠ΅ΠΌΠ°ΠΌΠ΅, Ρ‡Π΅ всички доставчкици са свободни Π² ΠΌΠΎΠΌΠ΅Π½Ρ‚Π° Π½Π° ΠΏΠΎΡ€ΡŠΡ‡ΠΊΠ°Ρ‚Π°, Π° слСд нСя Ρ‚Π΅ Π½Π΅ промСнят локацията си Ρ‚.Π΅ остават Π² стартова позиция. +ΠŸΠΎΡΠΎΠΊΠΈΡ‚Π΅ Π·Π° Π΄Π²ΠΈΠΆΠ΅Π½ΠΈΠ΅ ΠΏΠΎ ΠΊΠ°Ρ€Ρ‚Π°Ρ‚Π° са 4 - Π½Π°Π³ΠΎΡ€Π΅, Π½Π°Π΄ΠΎΠ»Ρƒ, наляво ΠΈ надясно. Π”ΠΎΡΡ‚Π°Π²Ρ‡ΠΈΠΊΡŠΡ‚ ΠΌΠΎΠΆΠ΅ Π΄Π° ΠΏΡ€Π΅ΠΌΠΈΠ½Π°Π²Π° ΠΏΡ€Π΅Π· всичко, Ρ€Π°Π·Π»ΠΈΡ‡Π½ΠΎ ΠΎΡ‚ стСна (Π²ΠΊΠ»ΡŽΡ‡ΠΈΡ‚Π΅Π»Π½ΠΎ ΠΈ Π΄Ρ€ΡƒΠ³ΠΈ доставчици). ΠŸΡ€ΠΈΠ΅ΠΌΠ°ΠΌΠ΅, Ρ‡Π΅ всички доставчици са свободни Π² ΠΌΠΎΠΌΠ΅Π½Ρ‚Π° Π½Π° ΠΏΠΎΡ€ΡŠΡ‡ΠΊΠ°Ρ‚Π°, Π° слСд нСя Ρ‚Π΅ Π½Π΅ промСнят локацията си Ρ‚.Π΅. остават Π² стартова позиция. НапримСр: + ```java char[][] layout = { {'#', '#', '#', '.', '#'}, @@ -159,15 +172,19 @@ char[][] layout = { ``` ### ΠŸΠΎΠΌΠΎΡ‰Π½ΠΈ Ρ‚ΠΈΠΏΠΎΠ²Π΅ + ОсвСн основнитС класовС ΠΈ интСрфСйси, Π² условиСто ΠΈΠΌΠ° Π½ΡƒΠΆΠ΄Π° Π΄Π° Π΄Π΅Ρ„ΠΈΠ½ΠΈΡ€Π°ΠΌΠ΅ ΠΎΡ‰Π΅ няколко ΠΏΠΎΠΌΠΎΡ‰Π½ΠΈ класа/records. Π˜ΠΌΠΏΠ»Π΅ΠΌΠ΅Π½Ρ‚Π°Ρ†ΠΈΠΈΡ‚Π΅ Π²ΠΈ, СстСствСно, Π½Π΅ сС ΠΈΠ·Ρ‡Π΅Ρ€ΠΏΠ²Π°Ρ‚ с Ρ‚ΠΎΠ·ΠΈ Π½Π°Π±ΠΎΡ€ ΠΎΡ‚ Ρ‚ΠΈΠΏΠΎΠ²Π΅ ΠΈ спокойно ΠΌΠΎΠΆΠ΅ Π΄Π° Π΄Π΅Ρ„ΠΈΠ½ΠΈΡ€Π°Ρ‚Π΅ Π½ΠΎΠ²ΠΈ. ЕдинствСното условиС Π΅ Π΄Π° Π½Π΅ промСнятС Π²Π΅Ρ‡Π΅ Π΄Π°Π΄Π΅Π½ΠΈΡ‚Π΅ ΠΏΠΎ условиС Ρ‚Π°ΠΊΠΈΠ²Π°, Ρ‚Π΅Ρ…Π½ΠΈΡ‚Π΅ конструктори ΠΈ сигнатуритС Π½Π° ΠΌΠ΅Ρ‚ΠΎΠ΄ΠΈΡ‚Π΅ ΠΈΠΌ. #### Location -Location Π΅ част ΠΎΡ‚ ΠΏΠ°ΠΊΠ΅Ρ‚Π° `bg.sofia.uni.fmi.mjt.glovo.controlcenter.map`, Ρ€Π΅ΠΏΡ€Π΅Π·Π΅Π½Ρ‚ΠΈΡ€Π° ΠΊΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚ΠΈΡ‚Π΅ Π½Π° Π΄Π°Π΄Π΅Π½ΠΎ entity Π½Π° Π½Π°ΡˆΠ°Ρ‚Π° ΠΊΠ°Ρ€Ρ‚Π° ΠΈ ΠΈΠΌΠ° конструктор: + +`Location` Π΅ част ΠΎΡ‚ ΠΏΠ°ΠΊΠ΅Ρ‚Π° `bg.sofia.uni.fmi.mjt.glovo.controlcenter.map`, Ρ€Π΅ΠΏΡ€Π΅Π·Π΅Π½Ρ‚ΠΈΡ€Π° ΠΊΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚ΠΈΡ‚Π΅ Π½Π° Π΄Π°Π΄Π΅Π½ΠΎ entity Π½Π° Π½Π°ΡˆΠ°Ρ‚Π° ΠΊΠ°Ρ€Ρ‚Π° ΠΈ ΠΈΠΌΠ° слСдния конструктор: + ```java public Location(int x, int y) { ... } ``` #### Delivery + Π’ ΠΏΠ°ΠΊΠ΅Ρ‚Π° `bg.sofia.uni.fmi.mjt.glovo.delivery` ΡΡŠΠ·Π΄Π°ΠΉΡ‚Π΅ Π½ΠΎΠ² Java Ρ‚ΠΈΠΏ `Delivery`, ΠΊΠΎΠΉΡ‚ΠΎ ΠΈΠΌΠ° слСдния конструктор: ```java @@ -175,7 +192,8 @@ public Delivery(Location client, Location restaurant, Location deliveryGuy, Stri ``` #### DeliveryType -Π’ΠΈΠ΄ΡŠΡ‚ Π½Π° транспорта Π½Π° доставкитС сС ΠΌΠΎΠ΄Π΅Π»ΠΈΡ€Π° ΠΎΡ‚ enum `DeliveryType`, Π΄Π΅Ρ„ΠΈΠ½ΠΈΡ€Π°Π½ Π² `bg.sofia.uni.fmi.mjt.glovo.delivery` ΠΈ ΠΈΠΌΠ°Ρ‰ Π΄Π²Π΅ стойности, ΠΊΠΎΠΈΡ‚ΠΎ сС Ρ…Π°Ρ€Π°ΠΊΡ‚Π΅Ρ€ΠΈΠ·ΠΈΡ€Π°Ρ‚ с Ρ†Π΅Π½Π° Π½Π° ΠΊΠΈΠ»ΠΎΠΌΠ΅Ρ‚ΡŠΡ€ ΠΈ Π²Ρ€Π΅ΠΌΠ΅ Π·Π° ΠΈΠ·ΠΌΠΈΠ½Π°Π²Π°Π½Π΅ Π½Π° ΠΊΠΈΠ»ΠΎΠΌΠ΅Ρ‚ΡŠΡ€: + +Π’ΠΈΠ΄ΡŠΡ‚ Π½Π° транспорта Π½Π° доставкитС сС ΠΌΠΎΠ΄Π΅Π»ΠΈΡ€Π° ΠΎΡ‚ enum-Π° `DeliveryType`, Π΄Π΅Ρ„ΠΈΠ½ΠΈΡ€Π°Π½ Π² `bg.sofia.uni.fmi.mjt.glovo.delivery` ΠΈ ΠΈΠΌΠ°Ρ‰ Π΄Π²Π΅ стойности, ΠΊΠΎΠΈΡ‚ΠΎ сС Ρ…Π°Ρ€Π°ΠΊΡ‚Π΅Ρ€ΠΈΠ·ΠΈΡ€Π°Ρ‚ с Ρ†Π΅Π½Π° Π½Π° ΠΊΠΈΠ»ΠΎΠΌΠ΅Ρ‚ΡŠΡ€ ΠΈ Π²Ρ€Π΅ΠΌΠ΅ Π·Π° ΠΈΠ·ΠΌΠΈΠ½Π°Π²Π°Π½Π΅ Π½Π° ΠΊΠΈΠ»ΠΎΠΌΠ΅Ρ‚ΡŠΡ€: | `DeliveryType` | Price per kilometer | Time per kilometer | |----------------|---------------------|--------------------| @@ -183,7 +201,9 @@ public Delivery(Location client, Location restaurant, Location deliveryGuy, Stri | BIKE | 3 | 5 | #### Shipping method + ΠœΠ΅Ρ‚ΠΎΠ΄ΡŠΡ‚ Π½Π° доставка сС ΠΌΠΎΠ΄Π΅Π»ΠΈΡ€Π° ΠΎΡ‚ слСдния enum: + ```java package bg.sofia.uni.fmi.mjt.glovo.delivery; @@ -194,7 +214,9 @@ public enum ShippingMethod { ``` #### DeliveryInfo -ΠŸΠΎΡΠ»Π΅Π΄Π½ΠΈΡΡ‚ ΠΏΠΎΠΌΠΎΡ‰Π΅Π½ Ρ‚ΠΈΠΏ ΠΎΡ‚ ΠΏΠ°ΠΊΠ΅Ρ‚Π° `bg.sofia.uni.fmi.mjt.glovo.delivery` Π΅ `DeliveryInfo` - Ρ‚ΠΎΠΉ Π΅ Ρ€Π΅Π»Π΅Π²Π°Π½Ρ‚Π΅Π½ Π·Π° `ControlCenterAPI` интСрфСйса. Има слСдният конструктор: + +ΠŸΠΎΡΠ»Π΅Π΄Π½ΠΈΡΡ‚ ΠΏΠΎΠΌΠΎΡ‰Π΅Π½ Ρ‚ΠΈΠΏ ΠΎΡ‚ ΠΏΠ°ΠΊΠ΅Ρ‚Π° `bg.sofia.uni.fmi.mjt.glovo.delivery` Π΅ `DeliveryInfo` - Ρ‚ΠΎΠΉ Π΅ Ρ€Π΅Π»Π΅Π²Π°Π½Ρ‚Π΅Π½ Π·Π° `ControlCenterAPI` интСрфСйса ΠΈ ΠΈΠΌΠ° слСдния конструктор: + ```java public DeliveryInfo(Location deliveryGuyLocation, double price, int estimatedTime, DeliveryType deliveryType) ``` @@ -233,8 +255,27 @@ src ### :warning: Π—Π°Π±Π΅Π»Π΅ΠΆΠΊΠΈ - НС промСняйтС ΠΏΠΎ никакъв Π½Π°Ρ‡ΠΈΠ½ интСрфСйситС, Π΄Π°Π΄Π΅Π½ΠΈ Π² условиСто. -- :exclamation::exclamation: **РСшСния, - ΠΈΠ·ΠΏΠΎΠ»Π·Π²Π°Ρ‰ΠΈ [Java Stream API](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/stream/package-summary.html), +- :exclamation: **РСшСния, + ΠΈΠ·ΠΏΠΎΠ»Π·Π²Π°Ρ‰ΠΈ [Java Stream API](https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/util/stream/package-summary.html), [lambdas](https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html), ΠΈ всичко останало, ΠΊΠΎΠ΅Ρ‚ΠΎ Π½Π΅ Π΅ - ΠΏΠΎΠΊΡ€ΠΈΡ‚ΠΎ Π΄ΠΎ ΠΌΠΎΠΌΠ΅Π½Ρ‚Π°, няма Π΄Π° сС ΠΏΡ€ΠΈΠ΅ΠΌΠ°Ρ‚ Π·Π° Ρ‚ΠΎΠ²Π° домашно.** + ΡƒΡ‡Π΅Π½ΠΎ Π΄ΠΎ ΠΌΠΎΠΌΠ΅Π½Ρ‚Π° Π² курса, няма Π΄Π° сС ΠΏΡ€ΠΈΠ΅ΠΌΠ°Ρ‚ Π·Π° Ρ‚ΠΎΠ²Π° домашно.** + +### ΠŸΡ€Π΅Π΄Π°Π²Π°Π½Π΅ + +Π—Π° Π΄Π° ΠΏΡ€Π΅Π΄Π°Π΄Π΅Ρ‚Π΅ Ρ€Π΅ΡˆΠ΅Π½ΠΈΠ΅Ρ‚ΠΎ си, ΠΊΠ°Ρ‡Π΅Ρ‚Π΅ цялата `src` дирСктория Π½Π° ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π° Π² ΡΡŠΠΎΡ‚Π²Π΅Ρ‚Π½ΠΈΡ assignment Π² Π³Ρ€Π΅ΠΉΠ΄ΡŠΡ€Π° +(ΠΈΠ»ΠΈ я Π°Ρ€Ρ…ΠΈΠ²ΠΈΡ€Π°ΠΉΡ‚Π΅ Π² **zip** Ρ„Π°ΠΉΠ» ΠΈ ΠΊΠ°Ρ‡Π΅Ρ‚Π΅ Π½Π΅Π³ΠΎ). + +### ΠžΡ†Π΅Π½ΡΠ²Π°Π½Π΅ + +Π Π΅ΡˆΠ΅Π½ΠΈΠ΅Ρ‚ΠΎ ΠΌΠΎΠΆΠ΅ Π΄Π° Π²ΠΈ донСсС Π΄ΠΎ 100 Ρ‚ΠΎΡ‡ΠΊΠΈ, ΠΊΠ°Ρ‚ΠΎ Ρ‰Π΅ бъдС оцСнявано Π·Π°: + +* Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΎΠ½Π°Π»Π½Π° ΠΏΡŠΠ»Π½ΠΎΡ‚Π° ΠΈ корСктност: Ρ‡Ρ€Π΅Π· Π°Π²Ρ‚ΠΎΠΌΠ°Ρ‚ΠΈΡ‡Π½ΠΈ тСстовС (80% ΠΎΡ‚ ΠΎΡ†Π΅Π½ΠΊΠ°Ρ‚Π°) +* Π΄ΠΎΠ±ΡŠΡ€ ΠΎΠ±Π΅ΠΊΡ‚Π½ΠΎ-ΠΎΡ€ΠΈΠ΅Π½Ρ‚ΠΈΡ€Π°Π½ Π΄ΠΈΠ·Π°ΠΉΠ½, спазванС Π½Π° ΠΏΡ€Π°Π²ΠΈΠ»Π°Ρ‚Π° Π·Π° чист ΠΊΠΎΠ΄ ΠΈ ΠΏΠΎΠ΄Π±ΠΈΡ€Π°Π½Π΅ Π½Π° ΠΎΠΏΡ‚ΠΈΠΌΠ°Π»Π½ΠΈ Π·Π° Π·Π°Π΄Π°Ρ‡Π°Ρ‚Π° структури ΠΎΡ‚ + Π΄Π°Π½Π½ΠΈ (20% ΠΎΡ‚ ΠΎΡ†Π΅Π½ΠΊΠ°Ρ‚Π°) + +ΠžΠ±ΡŠΡ€Π½Π΅Ρ‚Π΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅, Ρ‡Π΅ ΠΏΡ€ΠΈ ΠΊΠ°Ρ‡Π²Π°Π½Π΅ Π½Π° Ρ€Π΅ΡˆΠ΅Π½ΠΈΠ΅Ρ‚ΠΎ Π²ΠΈ, Π² Π³Ρ€Π΅ΠΉΠ΄ΡŠΡ€Π° Ρ‰Π΅ сС изпълни само _smoke_ тСст, чиято Ρ†Π΅Π» Π΅ Π΄Π° изчиститС +Π΅Π²Π΅Π½Ρ‚ΡƒΠ°Π»Π½ΠΈ ΠΏΡ€ΠΎΠ±Π»Π΅ΠΌΠΈ с компилацията. Π Π΅Ρ„Π΅Ρ€Π΅Π½Ρ‚ΠΈΡ‚Π΅ тСстовС ΠΈ Checkstyle статичният ΠΊΠΎΠ΄ Π°Π½Π°Π»ΠΈΠ· Ρ‰Π΅ сС ΠΈΠ·ΠΏΡŠΠ»Π½ΡΡ‚ Π΅Π΄Π½ΠΎΠΊΡ€Π°Ρ‚Π½ΠΎ +слСд ΠΈΠ·Ρ‚ΠΈΡ‡Π°Π½Π΅ Π½Π° крайния срок Π·Π° ΠΏΡ€Π΅Π΄Π°Π²Π°Π½Π΅. Π—Π° Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΎΠ½Π°Π»Π½Π°Ρ‚Π° корСктност ΠΈ качСството Π½Π° ΠΊΠΎΠ΄Π° Ρ‰Π΅ трябва Π΄Π° сС ΠΏΠΎΠ³Ρ€ΠΈΠΆΠΈΡ‚Π΅ +Π±Π΅Π· тяхната ΠΏΠΎΠΌΠΎΡ‰. +### Π–Π΅Π»Π°Π΅ΠΌ Π²ΠΈ успСх! :four_leaf_clover: diff --git a/homeworks/README.md b/homeworks/README.md new file mode 100644 index 00000000..da0a7570 --- /dev/null +++ b/homeworks/README.md @@ -0,0 +1,5 @@ +# Π”ΠΎΠΌΠ°ΡˆΠ½ΠΈ + +| # | УсловиС | ΠšΡ€Π°Π΅Π½ срок | +|:--|:-------------------------------------------------------------------------- |:---------------- | +| 1 | [Glovo](https://github.com/fmi/java-course/tree/master/homeworks/01-glovo) | 30.11.2024 23:59 |