-
Notifications
You must be signed in to change notification settings - Fork 1
Добавил поиск #19
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
y0shir
wants to merge
13
commits into
main
Choose a base branch
from
dev_sorting
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
Добавил поиск #19
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8cff1ba
Притивы int заменены на Integer в классах Book, RootVegetable, рандом…
Nick-Che 1f7b2c0
Рандомайзеры работают по паттерну стратегия
Nick-Che 59b5ce5
обновлено меню. работают функции добавление в массив элементов с ранд…
Nick-Che f51c930
Добавил класс Pair, он просто хранит два класса для удобства
y0shir 345ae10
Преработал класс Menu для большей модульнести
y0shir a4d5251
нет времени
y0shir f36fea3
Разделил Storage по типам, добавил поиск
y0shir 1db9a3f
Добавил комментариев
y0shir bdfce3c
Догнал main
y0shir eb55bae
Merge branch 'farlenkov_ivan' into dev_sorting
y0shir de2926f
Поправил название переменной
y0shir c5c4ffd
Поменял исключение на SOUT
y0shir aa84f1f
Переделал методы на void вместо возвращения родительского объекта
y0shir 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,5 @@ | ||
| class AuthorOfBook extends ValueGetter<Book, java.lang.String>{ | ||
| public java.lang.String get(Book book){ | ||
| return book.getAuthor(); | ||
| } | ||
| } | ||
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
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,5 @@ | ||
| class ColourOfRV extends ValueGetter<RootVegetable, java.lang.String>{ | ||
| public java.lang.String get(RootVegetable rv){ | ||
| return rv.getColour(); | ||
| } | ||
| } |
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
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
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
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,5 @@ | ||
| class ModelOfCar extends ValueGetter<Car, java.lang.String>{ | ||
| public java.lang.String get(Car car){ | ||
| return car.getModel(); | ||
| } | ||
| } |
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,8 @@ | ||
| class MultiBinarySearch<T>{ | ||
| /* | ||
| private LinkedList<BinarySearch> searches; | ||
| private class BinarySearchContainer | ||
| public class MultiBinarySearchBuilder(){ | ||
|
|
||
| }*/ | ||
| } |
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,5 @@ | ||
| class PagesOfBook extends ValueGetter<Book, java.lang.Integer>{ | ||
| public java.lang.Integer get(Book book){ | ||
| return book.getPages(); | ||
| } | ||
| } |
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,5 @@ | ||
| class PowerOfCar extends ValueGetter<Car, java.lang.Integer>{ | ||
| public java.lang.Integer get(Car car){ | ||
| return car.getPower(); | ||
| } | ||
| } |
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
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,62 @@ | ||
| import java.util.LinkedList; | ||
| import java.util.Scanner; | ||
| import java.util.function.Function; | ||
| import java.lang.String; | ||
| import java.lang.Exception; | ||
| import java.util.Optional; | ||
|
|
||
| class SearchAction<O,V> implements MenuAction{ | ||
| //Обрабатывает запрос поиска и выводит результат | ||
| private static Scanner scan= new Scanner(System.in); | ||
| public Main.datatype class_selector; | ||
| public ValueGetter<O,V> getter; | ||
| CustomComparator<V> comp; | ||
| public Function<String,V> parser; | ||
|
|
||
| public SearchAction setGetter(ValueGetter<O,V> getter){ | ||
| this.getter=getter; | ||
| return this; | ||
| } | ||
|
|
||
| public SearchAction setComp(CustomComparator<V> comp){ | ||
| this.comp=comp; | ||
| return this; | ||
| } | ||
|
|
||
| public SearchAction setParser(Function<String,V> parser){ | ||
| this.parser=parser; | ||
| return this; | ||
| } | ||
|
|
||
| public SearchAction setSelector(Main.datatype i){ | ||
| class_selector=i; | ||
| return this; | ||
| } | ||
|
|
||
| public void execute(){ | ||
| BinarySearch<O,V> search=new BinarySearch<O,V>(); | ||
| Optional<O> result; | ||
| Storage<O> storage= Storage.<O>getInstance(class_selector); | ||
| search=search. new BinarySearchBuilder(). | ||
| addObjects(storage.getObjects()). | ||
| setGetter(getter). | ||
| setComparator(comp).build(); | ||
| while(true){ | ||
| System.out.print("Запрос:"); | ||
| String input=scan.nextLine(); | ||
| V search_value; | ||
| try{ | ||
| search_value=parser.apply(input); | ||
| }catch(Exception e){ | ||
| System.out.println(e.toString()); | ||
| continue; | ||
| } | ||
| result = search.findObject(search_value); | ||
| if(result.isPresent()){ | ||
| break; | ||
| } | ||
| System.out.println("Не найдено"); | ||
| } | ||
| System.out.println(result.get().toString()); | ||
| } | ||
| } |
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
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,5 @@ | ||
| class TitleOfBook extends ValueGetter<Book, java.lang.String>{ | ||
| public java.lang.String get(Book book){ | ||
| return book.getTitle(); | ||
| } | ||
| } |
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,5 @@ | ||
| class TypeOfRV extends ValueGetter<RootVegetable, java.lang.String>{ | ||
| public java.lang.String get(RootVegetable rv){ | ||
| return rv.getType(); | ||
| } | ||
| } |
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,5 @@ | ||
| class WeightOfRV extends ValueGetter<RootVegetable, java.lang.Integer>{ | ||
| public java.lang.Integer get(RootVegetable rv){ | ||
| return rv.getWeight(); | ||
| } | ||
| } |
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,5 @@ | ||
| class YearOfCar extends ValueGetter<Car, java.lang.Integer>{ | ||
| public java.lang.Integer get(Car car){ | ||
| return car.getYearOfProduction(); | ||
| } | ||
| } |
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.
Ваня, у нас в самих классах Book, Car и т.п. есть get и set методы, ты зачем-то создаешь им дублеры
И ладно бы дублёры - на каждое поле отдельный класс. Это антипаттерн, имхо..
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.
Да, там есть сеттеры и геттеры, но их не досатать из дженериков