Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Commit b917e7d

Browse files
authored
Merge pull request #72 from ImSpaceLover/features/lab5
Лабораторная №5
2 parents cd2d533 + 7f37b2a commit b917e7d

File tree

51 files changed

+1503
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1503
-1
lines changed

students/23K0120/23K0120-p02/src/main/java/ru/mirea/practice/s23k0120/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ private Main() {
77
}
88

99
public static void main(String[] args) {
10-
System.out.println("Первая практическая работа!");
10+
System.out.println("Вторая практическая работа!");
1111
}
1212
}

students/23K0120/23K0120-p04/pom.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<artifactId>23K0120</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0120-p04</artifactId>
12+
<description>Enum</description>
13+
</project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package ru.mirea.practice.s23k0120;
2+
3+
public final class Main {
4+
5+
private Main() {
6+
7+
}
8+
9+
public static void main(String[] args) {
10+
System.out.println("Четвёртая практическая работа!");
11+
}
12+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package ru.mirea.practice.s23k0120.atelier;
2+
3+
public abstract class Atelier {
4+
5+
public static void dressMan(Clothes[] clothes) {
6+
for (Clothes clothe : clothes) {
7+
if (clothe instanceof MenClothing) {
8+
((MenClothing) clothe).dressMan();
9+
System.out.print('\n');
10+
}
11+
}
12+
}
13+
14+
public static void dressWoman(Clothes[] clothes) {
15+
for (Clothes clothe : clothes) {
16+
if (clothe instanceof WomenClothing) {
17+
((WomenClothing) clothe).dressWoman();
18+
System.out.print('\n');
19+
}
20+
}
21+
}
22+
23+
public static void main(String[] args) {
24+
Clothes[] clothes = new Clothes[4];
25+
26+
clothes[0] = new TShirt(ClothingSizes.XXS, 1000, "Красный");
27+
clothes[1] = new Pants(ClothingSizes.M, 5000, "Синий");
28+
clothes[2] = new Skirt(ClothingSizes.L, 10000, "Чёрный");
29+
clothes[3] = new Tie(ClothingSizes.S, 2000, "Зелёный");
30+
31+
dressMan(clothes);
32+
dressWoman(clothes);
33+
}
34+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package ru.mirea.practice.s23k0120.atelier;
2+
3+
4+
import java.text.NumberFormat;
5+
import java.util.Locale;
6+
7+
public abstract class Clothes {
8+
ClothingSizes size;
9+
float cost;
10+
String color;
11+
12+
public Clothes(ClothingSizes size, float cost, String color) {
13+
this.size = size;
14+
this.cost = cost;
15+
this.color = color;
16+
}
17+
18+
public String getDescription() {
19+
NumberFormat format = NumberFormat.getCurrencyInstance(new Locale("ru", "Ru"));
20+
return String.format("%s, Цена: %s, Цвет: %s", size, format.format(cost), color);
21+
}
22+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package ru.mirea.practice.s23k0120.atelier;
2+
3+
public enum ClothingSizes {
4+
XXS(32), XS(34), S(36), M(38), L(40);
5+
6+
final int euroSize;
7+
8+
ClothingSizes(int euroSize) {
9+
this.euroSize = euroSize;
10+
}
11+
12+
public String getDescription() {
13+
if (euroSize >= 34) {
14+
return "Взрослый размер";
15+
} else {
16+
return "Детский размер";
17+
}
18+
}
19+
20+
@Override
21+
public String toString() {
22+
return String.format("%s, %d", getDescription(), this.euroSize);
23+
}
24+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package ru.mirea.practice.s23k0120.atelier;
2+
3+
public interface MenClothing {
4+
void dressMan();
5+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package ru.mirea.practice.s23k0120.atelier;
2+
3+
public class Pants extends Clothes implements MenClothing, WomenClothing {
4+
public Pants(ClothingSizes size, float cost, String color) {
5+
super(size, cost, color);
6+
}
7+
8+
@Override
9+
public void dressMan() {
10+
System.out.printf("Мужские Брюки %s", getDescription());
11+
}
12+
13+
@Override
14+
public void dressWoman() {
15+
System.out.printf("Женские Брюки %s", getDescription());
16+
}
17+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package ru.mirea.practice.s23k0120.atelier;
2+
3+
public class Skirt extends Clothes implements WomenClothing {
4+
public Skirt(ClothingSizes size, float cost, String color) {
5+
super(size, cost, color);
6+
}
7+
8+
@Override
9+
public void dressWoman() {
10+
System.out.printf("Юбка %s", getDescription());
11+
}
12+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package ru.mirea.practice.s23k0120.atelier;
2+
3+
public class TShirt extends Clothes implements MenClothing, WomenClothing {
4+
public TShirt(ClothingSizes size, float cost, String color) {
5+
super(size, cost, color);
6+
}
7+
8+
@Override
9+
public void dressMan() {
10+
System.out.printf("Мужская Футболка %s", getDescription());
11+
}
12+
13+
@Override
14+
public void dressWoman() {
15+
System.out.printf("Женская Футболка %s", getDescription());
16+
}
17+
}
18+

0 commit comments

Comments
 (0)