Skip to content
Open
Show file tree
Hide file tree
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 Apr 18, 2025
4174204
Lesson 14 task1
psychotrance Apr 18, 2025
a8ef03f
Lesson 14 task2
psychotrance Apr 18, 2025
33d9f6a
Lesson 16
psychotrance Apr 20, 2025
f7e44ea
Lesson 17 task 1 - 3
psychotrance Apr 21, 2025
40816a9
Lesson 18 task 1 - 2
psychotrance Apr 21, 2025
fdfa697
Lessons 14-17 Corrections
psychotrance Apr 23, 2025
4717c4e
Lessons 14-17 Corrections
psychotrance Apr 23, 2025
42f3661
Lesson 20 task1_catchException
psychotrance Apr 30, 2025
1f5b9df
Lesson 20 task1_throwsException
psychotrance Apr 30, 2025
694d1f1
Changes after threads)
psychotrance Apr 30, 2025
c0dc663
Changes after threads)
psychotrance Apr 30, 2025
b244003
Lesson 20 task 2-3
psychotrance May 1, 2025
f74c5ff
Lesson 21 task1
psychotrance May 1, 2025
91a1edc
Lesson 25 task1-2(anonymous_class)
psychotrance May 9, 2025
a1d2b21
Lesson 25 task1-2(inner_class)
psychotrance May 10, 2025
3da4977
Lesson 25 task1-2(static_class)
psychotrance May 10, 2025
4c13381
Lesson 25 task1-2(static_class)
psychotrance May 10, 2025
fead10a
Lesson 25 task1-2(static_class)
psychotrance May 10, 2025
3842b90
Lesson 26 task1
psychotrance May 13, 2025
2eddc7d
Lesson 26 task1
psychotrance May 13, 2025
349fc6b
Lesson 26 task2
psychotrance May 19, 2025
cfd6e6e
Lesson 26 task2
psychotrance May 19, 2025
322d074
Lesson 28 task1
psychotrance May 21, 2025
d938ac3
Lesson 28 task2&task3
psychotrance May 22, 2025
8b11549
Lesson 28 task1 - 3
psychotrance May 24, 2025
20b9d93
Lesson 28 task1 - 3
psychotrance May 24, 2025
db1a6d5
Lesson 28 task1 - 3
psychotrance May 24, 2025
325e59f
PR changes
psychotrance Jun 2, 2025
4b1fba6
PR changes
psychotrance Jun 4, 2025
b589bae
PR changes
psychotrance Jun 9, 2025
0f37fcb
PR changes
psychotrance Jun 14, 2025
8844723
PR changes
psychotrance Jun 14, 2025
e7ad974
Lesson 29 task1
psychotrance Jun 17, 2025
d966f77
Lesson 29 task2
psychotrance Jun 17, 2025
766f8e0
Lesson 29 task2
psychotrance Jun 17, 2025
e33c792
Lesson 30 task1
psychotrance Jun 20, 2025
fb863aa
Lesson 30 task1
psychotrance Jun 21, 2025
5eea9f0
Lesson 30 task2
psychotrance Jun 22, 2025
51aeb46
Lesson 30 task3 not over
psychotrance Jun 22, 2025
cbe86dc
Lesson 31
psychotrance Jun 23, 2025
b6ad8e5
Lesson 31
psychotrance Jun 23, 2025
2ca72ef
Lesson 17-30 PR changes
psychotrance Jun 27, 2025
339cd69
Lesson 32 task1
psychotrance Jun 29, 2025
17108ab
Lesson 32 task2
psychotrance Jun 29, 2025
f7e9d8a
Lesson 32 task2
psychotrance Jun 29, 2025
3080b58
Lesson 32 task2
psychotrance Jun 29, 2025
a3714cf
PR changes
psychotrance Jun 30, 2025
96a1705
Lesson 32 task1-3
psychotrance Jul 4, 2025
9abeb90
Lesson 32 task1-3
psychotrance Jul 4, 2025
c08eeb7
Lesson 32 task1-2 (please don't check task-3: it's not over)
psychotrance Jul 7, 2025
0550004
Lesson 34 task1
psychotrance Jul 11, 2025
5a0addc
Lesson 33 task1-2 minor changes
psychotrance Jul 13, 2025
afd25ba
Lesson 34 task2-3
psychotrance Jul 20, 2025
72dae61
Lesson 30 task1-2 PR-changes
psychotrance Jul 21, 2025
299ec6d
Lesson 30 task1-2 PR-changes
psychotrance Jul 21, 2025
d1056c9
Lesson 28 minor changes
psychotrance Jul 26, 2025
eda5ea7
Lesson 38 task1
psychotrance Jul 26, 2025
e188d2e
Lesson 38 task2
psychotrance Jul 26, 2025
d9da80e
Lesson 38 task2
psychotrance Jul 26, 2025
9dadf6c
Lesson 39 task1
psychotrance Jul 29, 2025
5878545
Lesson 39 task1
psychotrance Jul 29, 2025
36fbb12
Lesson 39 task2
psychotrance Jul 29, 2025
99ebb10
Lesson 30 tasks30-38 PR changes
psychotrance Jul 30, 2025
32998a0
Lesson 30 tasks30-38 PR changes
psychotrance Jul 30, 2025
75a38e1
Lesson 37 Task2
psychotrance Jul 31, 2025
ede7159
Lesson 37 Task2
psychotrance Jul 31, 2025
7c67c0c
Lesson 38 task3
psychotrance Jul 31, 2025
699ae85
Lesson 38 task3
psychotrance Jul 31, 2025
0f8c307
Lesson 38 task4
psychotrance Aug 1, 2025
460899f
Lesson 40 task1
psychotrance Aug 4, 2025
4775229
Lesson 40 task1
psychotrance Aug 4, 2025
233b347
Lesson 40 task1 small changes
psychotrance Aug 4, 2025
1b7e389
Lesson 41 task1
psychotrance Aug 5, 2025
77d0ee4
Lesson 41 task2
psychotrance Aug 6, 2025
1f8271f
Lesson 42 task1 easy
psychotrance Aug 17, 2025
97cd9ce
Lesson 38-39 after-pr changes
psychotrance Aug 17, 2025
9f440c5
Lesson 42 task1-easy
psychotrance Aug 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions resource/files/lesson32_files_1/task1/carCatalog.txt
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
10 changes: 10 additions & 0 deletions resource/files/lesson32_files_1/task2/carCatalog.txt
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
40 changes: 40 additions & 0 deletions src/com/walking/lesson14_polymorphism/task1/Main.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.walking.lesson14_polymorphism.task1;

import com.walking.lesson14_polymorphism.task1.model.RegularFigure;
import com.walking.lesson14_polymorphism.task1.model.Square;
import com.walking.lesson14_polymorphism.task1.model.Triangle;

import java.util.Scanner;

/**
* Реализуйте класс «Правильная фигура».
* Для него создайте классы-наследники «Треугольник» и «Квадрат».
Expand All @@ -10,7 +16,41 @@
* <p>
* Обратите внимание, символ '\' в Java необходимо экранировать: '\\'.
*/

public class Main {
public static final Scanner SCANNER = new Scanner(System.in);
public static final String MENU = """
1. Triangle
2. Square

Make your choice:""";

public static void main(String[] args) {
int figureType = requireInt(MENU);

int length = requireInt("Enter a length: ");

System.out.println(createFigure(figureType, length));
}

private static String createFigure(int figureType, int length) {
RegularFigure figure;

switch (figureType) {
case 1:
figure = new Triangle(length);
break;
case 2:
figure = new Square(length);
break;
default:
figure = new RegularFigure(length);
}
return figure.getFigure();
}

public static int requireInt(String message) {
System.out.print(message);
return SCANNER.nextInt();
}
}
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 src/com/walking/lesson14_polymorphism/task1/model/Square.java
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 src/com/walking/lesson14_polymorphism/task1/model/Triangle.java
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;
}
}
15 changes: 15 additions & 0 deletions src/com/walking/lesson14_polymorphism/task2/Main.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.walking.lesson14_polymorphism.task2;

import com.walking.lesson14_polymorphism.task2.model.Animal;
import com.walking.lesson14_polymorphism.task2.model.Cat;
import com.walking.lesson14_polymorphism.task2.model.Cow;
import com.walking.lesson14_polymorphism.task2.model.Dog;

/**
* Используя новые знания, упростите реализацию задачи 2 из предыдущего урока:
* <a href="https://telegra.ph/Nasledovanie-Klyuchevoe-slovo-extends-i-ispolzovanie-protected-Klyuchevoe-slovo-super-Privedenie-ssylochnyh-tipov-11-23">...</a>
Expand All @@ -8,7 +13,17 @@
* <p>
* Использовать отдельное поле для хранения выводимой строки — недопустимо:)
*/

public class Main {
public static void main(String[] args) {
Animal[] animals = new Animal[]{new Cat(), new Cow(), new Dog()};

soundAll(animals);
}

private static void soundAll(Animal[] animals) {
for (Animal x : animals) {
x.sound();
}
}
}
8 changes: 8 additions & 0 deletions src/com/walking/lesson14_polymorphism/task2/model/Animal.java
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");
}
}
9 changes: 9 additions & 0 deletions src/com/walking/lesson14_polymorphism/task2/model/Cat.java
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");
}
}
9 changes: 9 additions & 0 deletions src/com/walking/lesson14_polymorphism/task2/model/Cow.java
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");
}
}
9 changes: 9 additions & 0 deletions src/com/walking/lesson14_polymorphism/task2/model/Dog.java
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");
}
}
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();
}
}
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();
}
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;
}
}
Loading