-
Notifications
You must be signed in to change notification settings - Fork 0
Homework 1 #1
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
Open
volukrem
wants to merge
6
commits into
main
Choose a base branch
from
hw_1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Homework 1 #1
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2878db9
определены методы и классы для работы CarShop с хранением данных в ко…
volukrem 8f4f3e9
Update readme.md
volukrem 5f1e649
clean up
volukrem dc67ce0
50% tests
volukrem c51d525
typo fix
volukrem 14c8214
Update readme.md
volukrem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <module type="JAVA_MODULE" version="4"> | ||
| <component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
| <exclude-output /> | ||
| <content url="file://$MODULE_DIR$"> | ||
| <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
| </content> | ||
| <orderEntry type="inheritedJdk" /> | ||
| <orderEntry type="sourceFolder" forTests="false" /> | ||
| </component> | ||
| </module> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>org.example</groupId> | ||
| <artifactId>carshop</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
|
|
||
| <properties> | ||
| <maven.compiler.source>17</maven.compiler.source> | ||
| <maven.compiler.target>17</maven.compiler.target> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| <jupiter.version>5.10.0</jupiter.version> | ||
| <assertj.version>3.24.2</assertj.version> | ||
| <mokito.version>4.8.1</mokito.version> | ||
| <jacoco.version>0.8.7</jacoco.version> | ||
| <lombok.version>1.18.30</lombok.version> | ||
| </properties> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter-api</artifactId> | ||
| <version>${jupiter.version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter-engine</artifactId> | ||
| <version>${jupiter.version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.assertj</groupId> | ||
| <artifactId>assertj-core</artifactId> | ||
| <version>${assertj.version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.mockito</groupId> | ||
| <artifactId>mockito-core</artifactId> | ||
| <version>${mokito.version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.projectlombok</groupId> | ||
| <artifactId>lombok</artifactId> | ||
| <version>${lombok.version}</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.jacoco</groupId> | ||
| <artifactId>jacoco-maven-plugin</artifactId> | ||
| <version>${jacoco.version}</version> | ||
| <executions> | ||
| <execution> | ||
| <goals> | ||
| <goal>prepare-agent</goal> | ||
| </goals> | ||
| </execution> | ||
| <execution> | ||
| <id>report</id> | ||
| <phase>test</phase> | ||
| <goals> | ||
| <goal>report</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,23 @@ | ||
| # | ||
| # Car Shop Management Application | ||
|
|
||
| ## Описание | ||
| Это приложение предназначено для управления автосалоном | ||
|
|
||
| ## Взаимодействие с программой | ||
| Интерфейс построен на вводе пользователем команд, предлагаемых для ввода программой в текущий момент времени | ||
| 1. Происходит регистрация/авторизация | ||
| 2. Отображение начального набора команд, в зависимости от роли пользователя | ||
| 3. Если роль администратор - CRUD автомобилей/заявок, создание/обновление данных о пользователях | ||
| 4. Если роль клиент - показ доступных для заказа автомобилей, показ заказов пользователя, формирование новых заказов | ||
|
|
||
| # Краткое описание классов | ||
| - Request - заказы на покупку, заявки на обслуживание | ||
| - User - пользователи (Клиенты, Менеджеры, Администраторы) | ||
| - Car - автомобили салона | ||
|
|
||
| + CarShopService - управление коллекцией автомобилей | ||
| + RequestService - управление коллекцией заказов | ||
| + UserService - управление коллекцией пользователей | ||
|
|
||
| * ConsoleUI - текстовое представление наборов команд | ||
| * UserConsole - управление вводом пользователя |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package org.example.carshop; | ||
|
|
||
| import org.example.carshop.factory.RequestRepositoryFactory; | ||
| import org.example.carshop.factory.CarRepositoryFactory; | ||
| import org.example.carshop.factory.UserRepositoryFactory; | ||
| import org.example.carshop.in.UserConsole; | ||
| import org.example.carshop.factory.RequestServiceFactory; | ||
| import org.example.carshop.factory.CarshopServiceFactory; | ||
| import org.example.carshop.factory.CarshopFactory; | ||
| import org.example.carshop.factory.UserConsoleFactory; | ||
| import org.example.carshop.factory.UserServiceFactory; | ||
| import org.example.carshop.repository.RequestRepository; | ||
| import org.example.carshop.repository.CarRepository; | ||
| import org.example.carshop.repository.UserRepository; | ||
| import org.example.carshop.service.RequestService; | ||
| import org.example.carshop.service.CarShopService; | ||
| import org.example.carshop.service.UserService; | ||
|
|
||
| public class Main { | ||
| public static void main(String[] args) { | ||
| CarshopFactory<UserRepository> userRepositoryFactory = new UserRepositoryFactory(); | ||
| CarshopFactory<RequestRepository> requestRepositoryFactory = new RequestRepositoryFactory(); | ||
| CarshopFactory<UserService> userServiceFactory = new UserServiceFactory(userRepositoryFactory); | ||
| CarshopFactory<UserConsole> userConsoleFactory = getUserConsoleCarshopFactory(requestRepositoryFactory, userServiceFactory); | ||
|
|
||
| UserConsole userConsole = userConsoleFactory.create(); | ||
| userConsole.runStartCommands(); | ||
| } | ||
|
|
||
| private static CarshopFactory<UserConsole> getUserConsoleCarshopFactory(CarshopFactory<RequestRepository> requestRepositoryFactory, CarshopFactory<UserService> userServiceFactory) { | ||
| CarshopFactory<CarRepository> carRepositoryFactory = new CarRepositoryFactory(); | ||
| CarshopFactory<CarShopService> carShopServiceFactory = new CarshopServiceFactory(carRepositoryFactory); | ||
| CarshopFactory<RequestService> requestServiceFactory = new RequestServiceFactory(requestRepositoryFactory); | ||
| return new UserConsoleFactory(userServiceFactory, carShopServiceFactory, requestServiceFactory); | ||
| } | ||
| } |
25 changes: 25 additions & 0 deletions
25
src/main/java/org/example/carshop/factory/CarRepositoryFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package org.example.carshop.factory; | ||
|
|
||
| import org.example.carshop.model.Car; | ||
| import org.example.carshop.repository.CarRepository; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Фабрика для создания объектов типа CarRepository. | ||
| * Реализует интерфейс CarshopFactory для создания экземпляров репозитория автомобилей. | ||
| */ | ||
| public class CarRepositoryFactory implements CarshopFactory<CarRepository> { | ||
|
|
||
| /** | ||
| * Создает и возвращает новый экземпляр CarRepository с пустым начальным маппингом автомобилей. | ||
| * | ||
| * @return новый экземпляр CarRepository | ||
| */ | ||
| @Override | ||
| public CarRepository create() { | ||
| Map<Integer, Car> carsHashMap = new HashMap<>(); | ||
| return new CarRepository(carsHashMap); | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
src/main/java/org/example/carshop/factory/CarshopFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package org.example.carshop.factory; | ||
|
|
||
| /** | ||
| * Интерфейс для общей фабрики, создающей экземпляры заданного типа. | ||
| * @param <T> тип объекта, который будет создаваться фабрикой. | ||
| */ | ||
| public interface CarshopFactory<T> { | ||
|
|
||
| /** | ||
| * Создает и возвращает новый экземпляр заданного типа. | ||
| * | ||
| * @return новый экземпляр заданного типа T. | ||
| */ | ||
| T create(); | ||
| } |
23 changes: 23 additions & 0 deletions
23
src/main/java/org/example/carshop/factory/CarshopServiceFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package org.example.carshop.factory; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import org.example.carshop.repository.CarRepository; | ||
| import org.example.carshop.service.CarShopService; | ||
|
|
||
| /** | ||
| * Фабрика для создания экземпляров {@link CarShopService}. | ||
| */ | ||
| @RequiredArgsConstructor | ||
| public class CarshopServiceFactory implements CarshopFactory<CarShopService> { | ||
| private final CarshopFactory<CarRepository> carRepositoryFactory; | ||
|
|
||
| /** | ||
| * Создает и возвращает новый экземпляр {@link CarShopService}. | ||
| * | ||
| * @return новый экземпляр {@link CarShopService}. | ||
| */ | ||
| @Override | ||
| public CarShopService create() { | ||
| return new CarShopService(carRepositoryFactory.create()); | ||
| } | ||
| } |
25 changes: 25 additions & 0 deletions
25
src/main/java/org/example/carshop/factory/RequestRepositoryFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package org.example.carshop.factory; | ||
|
|
||
| import org.example.carshop.model.Request; | ||
| import org.example.carshop.repository.RequestRepository; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Фабрика для создания объектов типа RequestRepository. | ||
| * Реализует интерфейс CarshopFactory для создания экземпляров репозитория заказов. | ||
| */ | ||
| public class RequestRepositoryFactory implements CarshopFactory<RequestRepository> { | ||
|
|
||
| /** | ||
| * Создает и возвращает новый экземпляр RequestRepository. | ||
| * | ||
| * @return новый экземпляр RequestRepository | ||
| */ | ||
| @Override | ||
| public RequestRepository create() { | ||
| Map<Integer, Request> requestHashMap = new HashMap<>(); | ||
| return new RequestRepository(requestHashMap); | ||
| } | ||
| } |
25 changes: 25 additions & 0 deletions
25
src/main/java/org/example/carshop/factory/RequestServiceFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package org.example.carshop.factory; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import org.example.carshop.repository.RequestRepository; | ||
| import org.example.carshop.service.RequestService; | ||
|
|
||
| /** | ||
| * Фабрика для создания объектов типа RequestService. | ||
| * Реализует интерфейс CarshopFactory для создания экземпляров сервиса заказов. | ||
| */ | ||
| @RequiredArgsConstructor | ||
| public class RequestServiceFactory implements CarshopFactory<RequestService> { | ||
| private final CarshopFactory<RequestRepository> requestRepositoryFactory; | ||
|
|
||
| /** | ||
| * Создает и возвращает новый экземпляр RequestService, используя фабрику requestRepositoryFactory | ||
| * для создания необходимого RequestService. | ||
| * | ||
| * @return новый экземпляр RequestService | ||
| */ | ||
| @Override | ||
| public RequestService create() { | ||
| return new RequestService(requestRepositoryFactory.create()); | ||
| } | ||
| } |
30 changes: 30 additions & 0 deletions
30
src/main/java/org/example/carshop/factory/UserConsoleFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package org.example.carshop.factory; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import org.example.carshop.in.UserConsole; | ||
| import org.example.carshop.service.RequestService; | ||
| import org.example.carshop.service.CarShopService; | ||
| import org.example.carshop.service.UserService; | ||
|
|
||
| /** | ||
| * Фабрика для создания экземпляров {@link UserConsole}. | ||
| */ | ||
| @RequiredArgsConstructor | ||
| public class UserConsoleFactory implements CarshopFactory<UserConsole> { | ||
| private final CarshopFactory<UserService> userServiceFactory; | ||
| private final CarshopFactory<CarShopService> carShopServiceFactory; | ||
| private final CarshopFactory<RequestService> requestServiceFactory; | ||
|
|
||
| /** | ||
| * Создает и возвращает новый экземпляр {@link UserConsole}. | ||
| * | ||
| * @return новый экземпляр {@link UserConsole}. | ||
| */ | ||
| @Override | ||
| public UserConsole create() { | ||
| UserService userService = userServiceFactory.create(); | ||
| CarShopService carShopService = carShopServiceFactory.create(); | ||
| RequestService requestService = requestServiceFactory.create(); | ||
| return new UserConsole(userService, carShopService, requestService); | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
src/main/java/org/example/carshop/factory/UserRepositoryFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package org.example.carshop.factory; | ||
|
|
||
| import org.example.carshop.model.User; | ||
| import org.example.carshop.repository.UserRepository; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Фабрика для создания экземпляров {@link UserRepository}. | ||
| */ | ||
| public class UserRepositoryFactory implements CarshopFactory<UserRepository> { | ||
|
|
||
| /** | ||
| * Создает и возвращает новый экземпляр {@link UserRepository}. | ||
| * | ||
| * @return новый экземпляр {@link UserRepository}. | ||
| */ | ||
| @Override | ||
| public UserRepository create() { | ||
| Map<String, User> userMap = new HashMap<>(); | ||
| return new UserRepository(userMap); | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
src/main/java/org/example/carshop/factory/UserServiceFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package org.example.carshop.factory; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import org.example.carshop.repository.UserRepository; | ||
| import org.example.carshop.service.UserService; | ||
|
|
||
| /** | ||
| * Фабрика для создания экземпляров {@link UserService}. | ||
| */ | ||
| @RequiredArgsConstructor | ||
| public class UserServiceFactory implements CarshopFactory<UserService> { | ||
| private final CarshopFactory<UserRepository> userRepositoryFactory; | ||
|
|
||
| /** | ||
| * Создает и возвращает новый экземпляр {@link UserService}. | ||
| * | ||
| * @return новый экземпляр {@link UserService}. | ||
| */ | ||
| @Override | ||
| public UserService create() { | ||
| return new UserService(userRepositoryFactory.create()); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Это не нужно в репо