Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
33563a1
решение
stillwearit Mar 10, 2025
318e3ed
lesson 16 task1 interface
stillwearit Mar 12, 2025
49bc972
я перепутала это был lesson 16 task2
stillwearit Mar 13, 2025
b98a860
lesson 16 task3
stillwearit Mar 13, 2025
f815be3
кириллица
stillwearit Mar 17, 2025
cf5894b
правки task14
stillwearit Mar 17, 2025
3901d07
правки lesson 16 task2
stillwearit Mar 17, 2025
d9e3347
правки lesson 16 task3
stillwearit Mar 17, 2025
d6417a6
правки lesson 16 task2
stillwearit Mar 17, 2025
34ef3fc
правки lesson 16 task1 абстрактный класс
stillwearit Mar 18, 2025
7ea65ff
правки lesson 17 task1
stillwearit Mar 18, 2025
da9f70b
правки lesson 17 task1
stillwearit Mar 18, 2025
6b72e7e
правки lesson 17 task2
stillwearit Mar 18, 2025
88b156b
lesson 17 task3
stillwearit Mar 19, 2025
68f2859
lesson 18 task1
stillwearit Mar 19, 2025
c09db58
lesson 18 task1 правки
stillwearit Mar 19, 2025
e95273d
lesson 18 task1 правки
stillwearit Mar 19, 2025
bdaa498
lesson 18 task1 правки
stillwearit Mar 19, 2025
e061808
lesson 19
stillwearit Mar 20, 2025
45633b9
lesson 19
stillwearit Mar 20, 2025
b852b24
lesson 19
stillwearit Mar 20, 2025
0ce340c
lesson 19
stillwearit Mar 21, 2025
364f204
lesson 14 правки
stillwearit Mar 25, 2025
3f65c1a
lesson 14 правки
stillwearit Mar 25, 2025
1975241
lesson 16 правки
stillwearit Mar 25, 2025
ee64b50
lesson 17 правки
stillwearit Mar 25, 2025
cf959f2
lesson 20, task 1
stillwearit Mar 31, 2025
581d8eb
lesson 20, task 1
stillwearit Mar 31, 2025
455de07
правки
stillwearit Mar 31, 2025
e125d86
lesson 20, task 1.2
stillwearit Mar 31, 2025
fe8d83f
lesson 20, task 1.2
stillwearit Mar 31, 2025
1fdcb45
lesson 20, task 2
stillwearit Apr 1, 2025
6a9497e
lesson 20, task 3
stillwearit Apr 1, 2025
97ae782
lesson 21
stillwearit Apr 3, 2025
ba035de
lesson 21
stillwearit Apr 3, 2025
dbcb8af
lesson 25, task 1, анонимные классы
stillwearit Apr 14, 2025
0ab1b7e
lesson 25, task 1, анонимные классы
stillwearit Apr 14, 2025
854c1b7
lesson 25, task 1, анонимные классы
stillwearit Apr 14, 2025
28bc2ac
lesson 25, task 1, внутренние классы
stillwearit Apr 14, 2025
5f13106
lesson 25, task 1, статические классы
stillwearit Apr 14, 2025
1f793d1
lesson 25, task 1, статические классы
stillwearit Apr 14, 2025
c975f83
lesson 25, task 2, анонимные классы
stillwearit Apr 15, 2025
570cd3b
lesson 25, task 2, внутренние классы
stillwearit Apr 15, 2025
2d5e2b4
lesson 25, task 2, внутренние классы
stillwearit Apr 15, 2025
db89cbc
lesson 25, task 2, static классы
stillwearit Apr 15, 2025
1613dc4
можно проверять всё в 25 уроке
stillwearit Apr 15, 2025
1c95eac
можно проверять всё в 25 уроке
stillwearit Apr 15, 2025
fb22c28
исправила 17-21
stillwearit Apr 19, 2025
0a713f0
урок 26, задание 1
stillwearit Apr 21, 2025
148cd15
урок 26, задание 1
stillwearit Apr 21, 2025
bbf9c23
урок 26, задание 1
stillwearit Apr 21, 2025
c5db7fd
урок 26, задание 2
stillwearit Apr 21, 2025
5583949
урок 26, задание 2
stillwearit Apr 22, 2025
e9eefe4
исправления
stillwearit Apr 28, 2025
4537115
lesson 28, task 1
stillwearit May 13, 2025
c93f510
lesson 28, task 2
stillwearit May 13, 2025
0a576e0
lesson 28, task 3
stillwearit May 13, 2025
6452514
lesson 29, task 1
stillwearit May 15, 2025
80bd8aa
lesson 29, task 2
stillwearit May 15, 2025
25abfcd
исправления
stillwearit May 28, 2025
4a00c95
исправления
stillwearit May 28, 2025
6d74fe0
lesson 30, task 1
stillwearit May 28, 2025
1b40cb1
lesson 30, task 2
stillwearit May 29, 2025
2e0b784
lesson 30, task 3
stillwearit May 29, 2025
c6d69e3
lesson 30, task 3
stillwearit Jun 9, 2025
bfd5100
lesson 31
stillwearit Jun 10, 2025
cb2ee42
lesson 31
stillwearit Jun 11, 2025
d4a4804
lesson 32, task 1
stillwearit Jun 13, 2025
407cfa3
lesson 32, task 2
stillwearit Jun 14, 2025
e3b5269
lesson 32, task 2
stillwearit Jun 14, 2025
6ad93a3
lesson 32, task 2
stillwearit Jun 14, 2025
c947ca7
lesson 32, task 2
stillwearit Jun 14, 2025
82fcc77
lesson 32, task 2
stillwearit Jun 14, 2025
a8af1d3
исправления
stillwearit Jun 16, 2025
f46b897
lesson 32, task 3
stillwearit Jun 27, 2025
901504e
lesson 32, task 3
stillwearit Jun 30, 2025
3f15ffd
lesson 33, task 1
stillwearit Jul 3, 2025
e566251
lesson 33, task 1
stillwearit Jul 3, 2025
1d546f2
lesson 33, task 2
stillwearit Jul 3, 2025
08f6031
lesson 33, task 2
stillwearit Jul 3, 2025
2b4e220
lesson 33, task 2
stillwearit Jul 3, 2025
103ce78
исправления
stillwearit Jul 9, 2025
ad8e5f5
исправления
stillwearit Jul 9, 2025
501306c
исправления
stillwearit Jul 10, 2025
7474b55
исправления
stillwearit Jul 10, 2025
c738c0b
lesson 34, task 1
stillwearit Jul 11, 2025
62e7730
lesson 34, task 2
stillwearit Jul 11, 2025
962c590
lesson 34, task 2
stillwearit Jul 11, 2025
5abfe49
исправления
stillwearit Jul 23, 2025
f1a7b9a
lesson 34, task 3
stillwearit Jul 23, 2025
5b17229
вроде исправила...
stillwearit Sep 10, 2025
68240ee
вроде исправила...
stillwearit Sep 10, 2025
751268c
исправила
stillwearit Sep 14, 2025
f6a2af0
lesson 37, task 1
stillwearit Sep 14, 2025
cdf1c4a
lesson 37, task 1
stillwearit Sep 14, 2025
6a664d3
lesson 37, task 1
stillwearit Sep 14, 2025
493af39
lesson 37, task 1
stillwearit Sep 14, 2025
347457c
lesson 37, task 1
stillwearit Sep 15, 2025
ffd43b2
lesson 37, task 1
stillwearit Sep 15, 2025
12c0215
lesson 37, task 2, ещё три метода...
stillwearit Sep 15, 2025
d406737
lesson 37, task 2, готово
stillwearit Sep 16, 2025
38caaf8
lesson 37, task 2, готово
stillwearit Sep 16, 2025
f5d11ff
lesson 37, task 2, готово
stillwearit Sep 16, 2025
eeb0e7f
lesson 38, task 1, готово
stillwearit Sep 22, 2025
f8585d4
lesson 38, task 2, готово
stillwearit Sep 24, 2025
d2b4906
исправления
stillwearit Sep 29, 2025
498141d
lesson 39, task 1
stillwearit Oct 1, 2025
78aa437
lesson 39, task 2
stillwearit Oct 2, 2025
df675a8
lesson 39, все задачи
stillwearit Oct 7, 2025
f92de7b
исправления
stillwearit Oct 8, 2025
d848de1
исправления
stillwearit Oct 8, 2025
4d7ed83
lesson 40, task
stillwearit Oct 9, 2025
f173163
исправления
stillwearit Oct 14, 2025
3a530fa
исправления
stillwearit Oct 15, 2025
7f9545f
lesson 41, task 1
stillwearit Oct 24, 2025
a2b7ca3
lesson 41, task 2
stillwearit Oct 24, 2025
8623eae
lesson 42, task1, балансировка
stillwearit Nov 8, 2025
49cb8be
lesson 42, task1, иии обход в ширину
stillwearit Nov 8, 2025
a2c243f
исправления
stillwearit Nov 8, 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
52 changes: 43 additions & 9 deletions src/com/walking/lesson14_polymorphism/task1/Main.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,50 @@
package com.walking.lesson14_polymorphism.task1;

import java.util.Scanner;

/**
* Реализуйте класс «Правильная фигура».
* Для него создайте классы-наследники «Треугольник» и «Квадрат».
* ���������� ����� ����������� ������.
* ��� ���� �������� ������-���������� ������������ � ��������.
* <p>
* Пользователь должен иметь возможность ввести длину стороны и выбрать тип фигуры.
* Программа должна нарисовать в консоли выбранную пользователем фигуру,
* используя символы '-', '|', '/', '\'.
* ������������ ������ ����� ����������� ������ ����� ������� � ������� ��� ������.
* ��������� ������ ���������� � ������� ��������� ������������� ������,
* ��������� ������� '-', '|', '/', '\'.
* <p>
* Обратите внимание, символ '\' в Java необходимо экранировать: '\\'.
* �������� ��������, ������ '\' Java ���������� ������������: '\\'.
*/
public class Main {
public static void main(String[] args) {
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("������� ��� ������: ");
String figureType = in.nextLine();
System.out.print("������� ����� �������: ");
int length = in.nextInt();

if (length < 1) {
System.out.println("������������ ����");
return;
}

RightFigure figure = new RightFigure(length);
createShape(figure, figureType);

}

private static void createShape(RightFigure figure, String figureType) {
switch (figureType.toLowerCase()) {
case Triangle.NAME:
figure = new Triangle(figure.length);
figure.getTheFigure();
break;
case Square.NAME:
figure = new Square(figure.length);
figure.getTheFigure();
break;
default:
figure.getTheFigure();
}
}
}
}
15 changes: 15 additions & 0 deletions src/com/walking/lesson14_polymorphism/task1/RightFigure.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.walking.lesson14_polymorphism.task1;

public class RightFigure {
int length;

public RightFigure(int length) {
this.length = length;
}

protected void getTheFigure() {
System.out.println("Íåèçâåñòíàÿ ôèãóðà");
}


}
30 changes: 30 additions & 0 deletions src/com/walking/lesson14_polymorphism/task1/Square.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.walking.lesson14_polymorphism.task1;

public class Square extends RightFigure {
public static final String NAME = "êâàäðàò";

private final String HORIZONTAL = "-";
private final String VERTICAL = "|";
private final String SPACE = " ";

public Square(int length) {
super(length);
}

@Override
public void getTheFigure() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

артикль в имени метода - это сильно:) но он не нужен

И почему void? Не логичнее получить строковое представление из метода? Кто знает, что нам с ним дальше делать? Мб в файл записать, мб в консоль вывести, мб еще чего:)

getHorizontalSide();
getVerticalSide();
getHorizontalSide();
}

private void getHorizontalSide() {
System.out.println(SPACE + HORIZONTAL.repeat(length - 2) + SPACE);
}

private void getVerticalSide() {
for(int i = 0; i < length - 2; i++) {
System.out.println(VERTICAL + SPACE.repeat(length - 2) + VERTICAL);
}
}
}
41 changes: 41 additions & 0 deletions src/com/walking/lesson14_polymorphism/task1/Triangle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.walking.lesson14_polymorphism.task1;

public class Triangle extends RightFigure {
public static final String NAME = "òðåóãîëüíèê";

private final String RIGHT_SIDE = "\\";
private final String LEFT_SIDE = "/";
private final String BOTTOM_SIDE = "_";
private final String SPACE = " ";

public Triangle(int length) {
super(length);
}

@Override
public void getTheFigure() {
getTriangle();
getBottomSide();
}

private void getBottomSide() {
System.out.println(LEFT_SIDE + BOTTOM_SIDE.repeat(length) + RIGHT_SIDE);
}

private void getTriangle() {
int k = length / 2;
int j;
if (length % 2 == 0) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А чем это, собственно, отличается от j = length % 2?)

j = 0;
} else {
j = 1;
}

for (int i = 0; i < length / 2; i++) {
System.out.println(SPACE.repeat(k) + LEFT_SIDE + SPACE.repeat(j) + RIGHT_SIDE);
k--;
j += 2;
}
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.walking.lesson16_abstract_class_interface.task1_interface;


/**
* Реализуйте задачу
* <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) {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.walking.lesson16_abstract_class_interface.task2;

public class Goodbye implements Printer {
final static String MASSAGE = "Bye";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

спорная история. К слову, Message

Такой подход подразумевает, что класс, использующий эту иерархию, знает обо всех наследниках. И именно в этой задаче (и предыдущей по полиморфизму) это отчасти оправдано. Но чаще всего иерархия нужна, чтобы работать с наследниками через супертип (обращаясь к ним, как к объекту Printer, в твоем случае). И неизвестно, что за потомок там будет. К нему может вообще не быть прямого доступа

final static String RESPOND = "Goodbye";

public static void print() {
System.out.println(RESPOND);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

забудь о такой практике) В абсолютном большинстве случаев метод должен что-то возвращать:) Откуда нам знать, что разработчик, использующий наш код, будет делать с этим методом? Или что тебе потребуется делать с результатом? В абсолютном большинстве случаев это будет не вывод в консоль

}
}
10 changes: 10 additions & 0 deletions src/com/walking/lesson16_abstract_class_interface/task2/Hello.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.walking.lesson16_abstract_class_interface.task2;

public class Hello implements Printer {
final static String MASSAGE = "Hi";
final static String RESPOND = "Hello";

public static void print() {
System.out.println(RESPOND);
}
}
10 changes: 10 additions & 0 deletions src/com/walking/lesson16_abstract_class_interface/task2/How.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.walking.lesson16_abstract_class_interface.task2;

public class How implements Printer {
final static String MASSAGE = "How are you";
final static String RESPOND = "How are you doing";

public static void print() {
System.out.println(RESPOND);
}
}
19 changes: 19 additions & 0 deletions src/com/walking/lesson16_abstract_class_interface/task2/Main.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
package com.walking.lesson16_abstract_class_interface.task2;

import java.util.Scanner;

/**
* Реализуйте задачу
* <a href="https://github.com/KFalcon2022/practical-tasks/blob/master/src/com/walking/lesson3/Task2SwitchCase.java">...</a>
* с использованием интерфейсов. Каждая реализация должна возвращать свое сообщение.
*/
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter massage: ");
String massage = in.nextLine();

switch (massage) {
case Hello.MASSAGE:
Hello.print();
break;
case Goodbye.MASSAGE:
Goodbye.print();
break;
case How.MASSAGE:
How.print();
break;
default:
Printer.print();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.walking.lesson16_abstract_class_interface.task2;

public interface Printer {

static void print() {
System.out.println("Unknown massage");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.walking.lesson16_abstract_class_interface.task3;

public abstract class Animal {

public Animal () {

}

abstract void sound();
}
14 changes: 14 additions & 0 deletions src/com/walking/lesson16_abstract_class_interface/task3/Cat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.walking.lesson16_abstract_class_interface.task3;

public class Cat extends Animal {
private final String SOUND = "meow";

public Cat() {
super();
}

public void sound() {
System.out.println(SOUND);
}

}
14 changes: 14 additions & 0 deletions src/com/walking/lesson16_abstract_class_interface/task3/Cow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.walking.lesson16_abstract_class_interface.task3;

public class Cow extends Animal {
private final String SOUND = "moo";

public Cow() {
super();
}

public void sound() {
System.out.println(SOUND);
}

}
14 changes: 14 additions & 0 deletions src/com/walking/lesson16_abstract_class_interface/task3/Dog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.walking.lesson16_abstract_class_interface.task3;

public class Dog extends Animal {
private final String SOUND = "woof";

public Dog() {
super();
}

public void sound() {
System.out.println(SOUND);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@
*/
public class Main {
public static void main(String[] args) {
Animal[] animals = new Animal[] {new Cow(), new Dog(), new Cat()};

for (Animal animal : animals) {
animal.sound();
}
}
}