-
Notifications
You must be signed in to change notification settings - Fork 103
For pr #111
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
psychotrance
wants to merge
78
commits into
KFalcon2022:for-pr
Choose a base branch
from
psychotrance:for-pr
base: for-pr
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
For pr #111
Changes from all commits
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
bf86994
Lesson 14 task1-2
psychotrance 4174204
Lesson 14 task1
psychotrance a8ef03f
Lesson 14 task2
psychotrance 33d9f6a
Lesson 16
psychotrance f7e44ea
Lesson 17 task 1 - 3
psychotrance 40816a9
Lesson 18 task 1 - 2
psychotrance fdfa697
Lessons 14-17 Corrections
psychotrance 4717c4e
Lessons 14-17 Corrections
psychotrance 42f3661
Lesson 20 task1_catchException
psychotrance 1f5b9df
Lesson 20 task1_throwsException
psychotrance 694d1f1
Changes after threads)
psychotrance c0dc663
Changes after threads)
psychotrance b244003
Lesson 20 task 2-3
psychotrance f74c5ff
Lesson 21 task1
psychotrance 91a1edc
Lesson 25 task1-2(anonymous_class)
psychotrance a1d2b21
Lesson 25 task1-2(inner_class)
psychotrance 3da4977
Lesson 25 task1-2(static_class)
psychotrance 4c13381
Lesson 25 task1-2(static_class)
psychotrance fead10a
Lesson 25 task1-2(static_class)
psychotrance 3842b90
Lesson 26 task1
psychotrance 2eddc7d
Lesson 26 task1
psychotrance 349fc6b
Lesson 26 task2
psychotrance cfd6e6e
Lesson 26 task2
psychotrance 322d074
Lesson 28 task1
psychotrance d938ac3
Lesson 28 task2&task3
psychotrance 8b11549
Lesson 28 task1 - 3
psychotrance 20b9d93
Lesson 28 task1 - 3
psychotrance db1a6d5
Lesson 28 task1 - 3
psychotrance 325e59f
PR changes
psychotrance 4b1fba6
PR changes
psychotrance b589bae
PR changes
psychotrance 0f37fcb
PR changes
psychotrance 8844723
PR changes
psychotrance e7ad974
Lesson 29 task1
psychotrance d966f77
Lesson 29 task2
psychotrance 766f8e0
Lesson 29 task2
psychotrance e33c792
Lesson 30 task1
psychotrance fb863aa
Lesson 30 task1
psychotrance 5eea9f0
Lesson 30 task2
psychotrance 51aeb46
Lesson 30 task3 not over
psychotrance cbe86dc
Lesson 31
psychotrance b6ad8e5
Lesson 31
psychotrance 2ca72ef
Lesson 17-30 PR changes
psychotrance 339cd69
Lesson 32 task1
psychotrance 17108ab
Lesson 32 task2
psychotrance f7e9d8a
Lesson 32 task2
psychotrance 3080b58
Lesson 32 task2
psychotrance a3714cf
PR changes
psychotrance 96a1705
Lesson 32 task1-3
psychotrance 9abeb90
Lesson 32 task1-3
psychotrance c08eeb7
Lesson 32 task1-2 (please don't check task-3: it's not over)
psychotrance 0550004
Lesson 34 task1
psychotrance 5a0addc
Lesson 33 task1-2 minor changes
psychotrance afd25ba
Lesson 34 task2-3
psychotrance 72dae61
Lesson 30 task1-2 PR-changes
psychotrance 299ec6d
Lesson 30 task1-2 PR-changes
psychotrance d1056c9
Lesson 28 minor changes
psychotrance eda5ea7
Lesson 38 task1
psychotrance e188d2e
Lesson 38 task2
psychotrance d9da80e
Lesson 38 task2
psychotrance 9dadf6c
Lesson 39 task1
psychotrance 5878545
Lesson 39 task1
psychotrance 36fbb12
Lesson 39 task2
psychotrance 99ebb10
Lesson 30 tasks30-38 PR changes
psychotrance 32998a0
Lesson 30 tasks30-38 PR changes
psychotrance 75a38e1
Lesson 37 Task2
psychotrance ede7159
Lesson 37 Task2
psychotrance 7c67c0c
Lesson 38 task3
psychotrance 699ae85
Lesson 38 task3
psychotrance 0f8c307
Lesson 38 task4
psychotrance 460899f
Lesson 40 task1
psychotrance 4775229
Lesson 40 task1
psychotrance 233b347
Lesson 40 task1 small changes
psychotrance 1b7e389
Lesson 41 task1
psychotrance 77d0ee4
Lesson 41 task2
psychotrance 1f8271f
Lesson 42 task1 easy
psychotrance 97cd9ce
Lesson 38-39 after-pr changes
psychotrance 9f440c5
Lesson 42 task1-easy
psychotrance 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,10 @@ | ||
| RR-111-RR;2015;yellow | ||
| RR-222-RR;2016;yellow | ||
| RR-333-RR;2017;yellow | ||
| RR-444-RR;2018;yellow | ||
| RR-555-RR;2018;yellow | ||
| RR-666-RR;2018;yellow | ||
| RR-777-RR;2018;yellow | ||
| RR-888-RR;2018;yellow | ||
| RR-999-RR;2018;yellow | ||
| RR-000-RR;2018;yellow |
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,10 @@ | ||
| RR-111-RR;2015;yellow | ||
| RR-222-RR;2016;yellow | ||
| RR-333-RR;2017;yellow | ||
| RR-444-RR;2018;yellow | ||
| RR-555-RR;2018;yellow | ||
| RR-666-RR;2018;yellow | ||
| RR-777-RR;2018;yellow | ||
| RR-888-RR;2018;yellow | ||
| RR-999-RR;2018;yellow | ||
| RR-000-RR;2018;yellow |
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
17 changes: 17 additions & 0 deletions
17
src/com/walking/lesson14_polymorphism/task1/model/RegularFigure.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,17 @@ | ||
| package com.walking.lesson14_polymorphism.task1.model; | ||
|
|
||
| public class RegularFigure { | ||
| public static final String EMPTY_UNIT = " "; | ||
| public static final String NEW_LINE_UNIT = "\n"; | ||
|
|
||
| public final int length; | ||
|
|
||
| public RegularFigure(int length) { | ||
| this.length = length; | ||
| } | ||
|
|
||
| public String getFigure() { | ||
| String figure = EMPTY_UNIT + NEW_LINE_UNIT; | ||
| return figure; | ||
| } | ||
| } |
43 changes: 43 additions & 0 deletions
43
src/com/walking/lesson14_polymorphism/task1/model/Square.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,43 @@ | ||
| package com.walking.lesson14_polymorphism.task1.model; | ||
|
|
||
| public class Square extends RegularFigure { | ||
| public static final String VERTICAL_LINE_UNIT = "|"; | ||
| public static final String HORIZONTAL_UNIT = "---"; | ||
|
|
||
| public Square(int length) { | ||
| super(length); | ||
| } | ||
|
|
||
| @Override | ||
| public String getFigure() { | ||
| return createHorizontalLine() + createVerticalLines() + createHorizontalLine(); | ||
|
|
||
| } | ||
|
|
||
| protected String createHorizontalLine() { | ||
| String horizontalLine = EMPTY_UNIT; | ||
| for (int i = 0; i < length; i++) { | ||
| horizontalLine += HORIZONTAL_UNIT; | ||
| } | ||
| horizontalLine += EMPTY_UNIT + NEW_LINE_UNIT; | ||
| return horizontalLine; | ||
| } | ||
|
|
||
| protected String createVerticalLines() { | ||
| String verticalLineUnit = createVerticalLineUnit(); | ||
| String verticalLines = ""; | ||
| for (int i = 0; i < length; i++) { | ||
| verticalLines += verticalLineUnit; | ||
| } | ||
| return verticalLines; | ||
| } | ||
|
|
||
| private String createVerticalLineUnit() { | ||
| String verticalLineUnit = VERTICAL_LINE_UNIT; | ||
| for (int i = 0; i < length * 3; i++) { | ||
| verticalLineUnit += EMPTY_UNIT; | ||
| } | ||
| verticalLineUnit += VERTICAL_LINE_UNIT + NEW_LINE_UNIT; | ||
| return verticalLineUnit; | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
src/com/walking/lesson14_polymorphism/task1/model/Triangle.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,50 @@ | ||
| package com.walking.lesson14_polymorphism.task1.model; | ||
|
|
||
| public class Triangle extends RegularFigure { | ||
| public static final String LEFT_SIDE_UNIT = "/"; | ||
| public static final String RIGHT_SIDE_UNIT = "\\"; | ||
| public static final String HORIZONTAL_UNIT = "--"; | ||
|
|
||
| public Triangle(int length) { | ||
| super(length); | ||
| } | ||
|
|
||
| @Override | ||
| public String getFigure() { | ||
| return createVerticalLines() + createHorizontalLine(); | ||
| } | ||
|
|
||
| protected String createHorizontalLine() { | ||
| String horizontalLine = EMPTY_UNIT; | ||
| for (int i = 0; i < length; i++) { | ||
| horizontalLine += HORIZONTAL_UNIT; | ||
| } | ||
| return horizontalLine + NEW_LINE_UNIT; | ||
| } | ||
|
|
||
| protected String createVerticalLines() { | ||
| String verticalLines = ""; | ||
| return createVerticalLines(length, length, verticalLines); | ||
| } | ||
|
|
||
| private String createVerticalLines(int width, int height, String verticalLines) { | ||
| for (int l = 0; l < height; l++) { | ||
| verticalLines += createVerticalLineUnit(width--, l); | ||
| } | ||
| return verticalLines; | ||
| } | ||
|
|
||
| private String createVerticalLineUnit(int width, int height) { | ||
| String verticalLineUnit = ""; | ||
| for (int before = width; before > 0; before--) { | ||
| verticalLineUnit += EMPTY_UNIT; | ||
| } | ||
| verticalLineUnit += LEFT_SIDE_UNIT; | ||
| for (int after = height * 2; after > 0; after--) { | ||
| verticalLineUnit += EMPTY_UNIT; | ||
| } | ||
| verticalLineUnit += RIGHT_SIDE_UNIT + NEW_LINE_UNIT; | ||
|
|
||
| return verticalLineUnit; | ||
| } | ||
| } |
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
8 changes: 8 additions & 0 deletions
8
src/com/walking/lesson14_polymorphism/task2/model/Animal.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,8 @@ | ||
| package com.walking.lesson14_polymorphism.task2.model; | ||
|
|
||
| public class Animal { | ||
|
|
||
| public void sound() { | ||
| System.out.println("Unknown animal"); | ||
| } | ||
| } |
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,9 @@ | ||
| package com.walking.lesson14_polymorphism.task2.model; | ||
|
|
||
| public class Cat extends Animal { | ||
|
|
||
| @Override | ||
| public void sound() { | ||
| System.out.println("meow"); | ||
| } | ||
| } |
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,9 @@ | ||
| package com.walking.lesson14_polymorphism.task2.model; | ||
|
|
||
| public class Cow extends Animal { | ||
|
|
||
| @Override | ||
| public void sound() { | ||
| System.out.println("moo"); | ||
| } | ||
| } |
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,9 @@ | ||
| package com.walking.lesson14_polymorphism.task2.model; | ||
|
|
||
| public class Dog extends Animal { | ||
|
|
||
| @Override | ||
| public void sound() { | ||
| System.out.println("woof"); | ||
| } | ||
| } |
39 changes: 39 additions & 0 deletions
39
src/com/walking/lesson16_abstract_class_interface/task1_abstract_class/Main.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 |
|---|---|---|
| @@ -1,11 +1,50 @@ | ||
| package com.walking.lesson16_abstract_class_interface.task1_abstract_class; | ||
|
|
||
| import com.walking.lesson16_abstract_class_interface.task1_abstract_class.model.EquiliteralShape; | ||
| import com.walking.lesson16_abstract_class_interface.task1_abstract_class.model.EquiliteralTriangle; | ||
| import com.walking.lesson16_abstract_class_interface.task1_abstract_class.model.Square; | ||
|
|
||
| import java.util.Scanner; | ||
|
|
||
| /** | ||
| * Реализуйте задачу | ||
| * <a href="https://github.com/KFalcon2022/practical-tasks/tree/master/src/com/walking/lesson14_polymorphism/task1">...</a> | ||
| * используя абстрактный класс. | ||
| */ | ||
| public class Main { | ||
| public static void main(String[] args) { | ||
| Scanner scanner = new Scanner(System.in); | ||
|
|
||
| System.out.print("Enter shape's length: "); | ||
| int length = scanner.nextInt(); | ||
|
|
||
| System.out.print("Enter shape's type:\n 1: Square\n 2: Triangle\n"); | ||
| int shapeType = scanner.nextInt(); | ||
|
|
||
| scanner.close(); | ||
|
|
||
| if (length < 1 || (shapeType != 1 && shapeType != 2)) { | ||
| System.out.println("Incorrect input"); | ||
| return; | ||
| } | ||
|
|
||
| String shapeString = createShapeString(length, shapeType); | ||
| System.out.println(shapeString); | ||
| } | ||
|
|
||
| private static String createShapeString(int length, int type) { | ||
| EquiliteralShape shape; | ||
|
|
||
| switch (type) { | ||
| case 1: | ||
| shape = new Square(length); | ||
| break; | ||
| case 2: | ||
| shape = new EquiliteralTriangle(length); | ||
| break; | ||
| default: | ||
| return "Unknown shape"; | ||
| } | ||
| return shape.createShapeString(); | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
...alking/lesson16_abstract_class_interface/task1_abstract_class/model/EquiliteralShape.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,19 @@ | ||
| package com.walking.lesson16_abstract_class_interface.task1_abstract_class.model; | ||
|
|
||
| public abstract class EquiliteralShape { | ||
| public static final String EMPTY_ELEMENT = " "; | ||
| public static final String EMPTY_STRING = ""; | ||
| public static final char NEW_LINE_SYMBOL = '\n'; | ||
|
|
||
| protected final int length; | ||
|
|
||
| public EquiliteralShape(int length) { | ||
| this.length = length; | ||
| } | ||
|
|
||
| public int getLength() { | ||
| return length; | ||
| } | ||
|
|
||
| public abstract String createShapeString(); | ||
| } |
35 changes: 35 additions & 0 deletions
35
...ing/lesson16_abstract_class_interface/task1_abstract_class/model/EquiliteralTriangle.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,35 @@ | ||
| package com.walking.lesson16_abstract_class_interface.task1_abstract_class.model; | ||
|
|
||
| public class EquiliteralTriangle extends EquiliteralShape { | ||
| public static final String TRIANGLE_HORIZONTAL_SIDE_ELEMENT = "--"; | ||
| public static final String TRIANGLE_LEFT_SIDE_ELEMENT = "/"; | ||
| public static final String TRIANGLE_RIGHT_SIDE_ELEMENT = "\\"; | ||
|
|
||
| public EquiliteralTriangle(int length) { | ||
| super(length); | ||
| } | ||
|
|
||
| @Override | ||
| public String createShapeString() { | ||
| String triangle = EMPTY_STRING; | ||
|
|
||
| for (int i = 0; i < length; i++) { | ||
| for (int j = 0; j < length - i; j++) { | ||
| triangle += EMPTY_ELEMENT; | ||
| } | ||
| triangle += TRIANGLE_LEFT_SIDE_ELEMENT; | ||
|
|
||
| for (int j = 0; j < i * 2; j++) { | ||
| triangle += EMPTY_ELEMENT; | ||
| } | ||
| triangle += TRIANGLE_RIGHT_SIDE_ELEMENT + NEW_LINE_SYMBOL; | ||
| } | ||
| triangle += EMPTY_ELEMENT; | ||
|
|
||
| for (int i = 0; i < length; i++) { | ||
| triangle += TRIANGLE_HORIZONTAL_SIDE_ELEMENT; | ||
| } | ||
|
|
||
| return triangle; | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.