This repository was archived by the owner on Dec 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
Лабораторная №4 #51
Merged
Merged
Лабораторная №4 #51
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8f51f46
Лабораторная №4
ImSpaceLover 043f7d6
Merge remote-tracking branch 'origin/features/lab4' into features/lab4
ImSpaceLover 8e588b5
Лабораторная №4
ImSpaceLover 7805ba8
Лабораторная №4 (Вер. 1.1)
ImSpaceLover 0372f12
Merge branch 'BasePractice:main' into features/lab4
ImSpaceLover c562a77
Merge remote-tracking branch 'origin/main' into features/lab4
ImSpaceLover 17bd5c0
Лабораторная №4 (Вер. 1.2)
ImSpaceLover 772c04b
Merge remote-tracking branch 'origin/features/lab4' into features/lab4
ImSpaceLover 3f311fb
Merge branch 'BasePractice:main' into features/lab4
ImSpaceLover 7f17317
Merge branch 'BasePractice:main' into features/lab4
ImSpaceLover 166bd12
Лабораторная №4
ImSpaceLover 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
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,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<artifactId>23K0120</artifactId> | ||
<groupId>ru.mirea.practice</groupId> | ||
<version>2024.1</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>23K0120-p04</artifactId> | ||
<description>Enum</description> | ||
</project> |
12 changes: 12 additions & 0 deletions
12
students/23K0120/23K0120-p04/src/main/java/ru/mirea/practice/s23k0120/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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ru.mirea.practice.s23k0120; | ||
|
||
public final class Main { | ||
|
||
private Main() { | ||
|
||
} | ||
|
||
public static void main(String[] args) { | ||
System.out.println("Четвёртая практическая работа!"); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
students/23K0120/23K0120-p04/src/main/java/ru/mirea/practice/s23k0120/atelier/Atelier.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,34 @@ | ||
package ru.mirea.practice.s23k0120.atelier; | ||
|
||
public abstract class Atelier { | ||
|
||
public static void dressMan(Clothes[] clothes) { | ||
for (Clothes clothe : clothes) { | ||
if (clothe instanceof MenClothing) { | ||
((MenClothing) clothe).dressMan(); | ||
System.out.print('\n'); | ||
} | ||
} | ||
} | ||
|
||
public static void dressWoman(Clothes[] clothes) { | ||
for (Clothes clothe : clothes) { | ||
if (clothe instanceof WomenClothing) { | ||
((WomenClothing) clothe).dressWoman(); | ||
System.out.print('\n'); | ||
} | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
Clothes[] clothes = new Clothes[4]; | ||
|
||
clothes[0] = new TShirt(ClothingSizes.XXS, 1000, "Красный"); | ||
clothes[1] = new Pants(ClothingSizes.M, 5000, "Синий"); | ||
clothes[2] = new Skirt(ClothingSizes.L, 10000, "Чёрный"); | ||
clothes[3] = new Tie(ClothingSizes.S, 2000, "Зелёный"); | ||
|
||
dressMan(clothes); | ||
dressWoman(clothes); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
students/23K0120/23K0120-p04/src/main/java/ru/mirea/practice/s23k0120/atelier/Clothes.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,22 @@ | ||
package ru.mirea.practice.s23k0120.atelier; | ||
|
||
|
||
import java.text.NumberFormat; | ||
import java.util.Locale; | ||
|
||
public abstract class Clothes { | ||
ClothingSizes size; | ||
float cost; | ||
String color; | ||
|
||
public Clothes(ClothingSizes size, float cost, String color) { | ||
this.size = size; | ||
this.cost = cost; | ||
this.color = color; | ||
} | ||
|
||
public String getDescription() { | ||
NumberFormat format = NumberFormat.getCurrencyInstance(new Locale("ru", "Ru")); | ||
return String.format("%s, Цена: %s, Цвет: %s", size, format.format(cost), color); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...s/23K0120/23K0120-p04/src/main/java/ru/mirea/practice/s23k0120/atelier/ClothingSizes.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,24 @@ | ||
package ru.mirea.practice.s23k0120.atelier; | ||
|
||
public enum ClothingSizes { | ||
XXS(32), XS(34), S(36), M(38), L(40); | ||
|
||
final int euroSize; | ||
|
||
ClothingSizes(int euroSize) { | ||
this.euroSize = euroSize; | ||
} | ||
|
||
public String getDescription() { | ||
if (euroSize >= 34) { | ||
return "Взрослый размер"; | ||
} else { | ||
return "Детский размер"; | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%s, %d", getDescription(), this.euroSize); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...nts/23K0120/23K0120-p04/src/main/java/ru/mirea/practice/s23k0120/atelier/MenClothing.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,5 @@ | ||
package ru.mirea.practice.s23k0120.atelier; | ||
|
||
public interface MenClothing { | ||
void dressMan(); | ||
} |
17 changes: 17 additions & 0 deletions
17
students/23K0120/23K0120-p04/src/main/java/ru/mirea/practice/s23k0120/atelier/Pants.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 ru.mirea.practice.s23k0120.atelier; | ||
|
||
public class Pants extends Clothes implements MenClothing, WomenClothing { | ||
public Pants(ClothingSizes size, float cost, String color) { | ||
super(size, cost, color); | ||
} | ||
|
||
@Override | ||
public void dressMan() { | ||
System.out.printf("Мужские Брюки %s", getDescription()); | ||
} | ||
|
||
@Override | ||
public void dressWoman() { | ||
System.out.printf("Женские Брюки %s", getDescription()); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
students/23K0120/23K0120-p04/src/main/java/ru/mirea/practice/s23k0120/atelier/Skirt.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,12 @@ | ||
package ru.mirea.practice.s23k0120.atelier; | ||
|
||
public class Skirt extends Clothes implements WomenClothing { | ||
public Skirt(ClothingSizes size, float cost, String color) { | ||
super(size, cost, color); | ||
} | ||
|
||
@Override | ||
public void dressWoman() { | ||
System.out.printf("Юбка %s", getDescription()); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
students/23K0120/23K0120-p04/src/main/java/ru/mirea/practice/s23k0120/atelier/TShirt.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,18 @@ | ||
package ru.mirea.practice.s23k0120.atelier; | ||
|
||
public class TShirt extends Clothes implements MenClothing, WomenClothing { | ||
public TShirt(ClothingSizes size, float cost, String color) { | ||
super(size, cost, color); | ||
} | ||
|
||
@Override | ||
public void dressMan() { | ||
System.out.printf("Мужская Футболка %s", getDescription()); | ||
} | ||
|
||
@Override | ||
public void dressWoman() { | ||
System.out.printf("Женская Футболка %s", getDescription()); | ||
} | ||
} | ||
|
12 changes: 12 additions & 0 deletions
12
students/23K0120/23K0120-p04/src/main/java/ru/mirea/practice/s23k0120/atelier/Tie.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,12 @@ | ||
package ru.mirea.practice.s23k0120.atelier; | ||
|
||
public class Tie extends Clothes implements MenClothing { | ||
public Tie(ClothingSizes size, float cost, String color) { | ||
super(size, cost, color); | ||
} | ||
|
||
@Override | ||
public void dressMan() { | ||
System.out.printf("Галстук %s", getDescription()); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...s/23K0120/23K0120-p04/src/main/java/ru/mirea/practice/s23k0120/atelier/WomenClothing.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,5 @@ | ||
package ru.mirea.practice.s23k0120.atelier; | ||
|
||
public interface WomenClothing { | ||
void dressWoman(); | ||
} |
12 changes: 12 additions & 0 deletions
12
students/23K0120/23K0120-p04/src/main/java/ru/mirea/practice/s23k0120/seasons/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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ru.mirea.practice.s23k0120.seasons; | ||
|
||
public abstract class Main { | ||
public static void main(String[] args) { | ||
Seasons season = Seasons.SPRING; | ||
System.out.printf("%s, Длится с 1 марта по 31 мая, Второе время года в году\n", season); | ||
|
||
for (Seasons s : Seasons.values()) { | ||
System.out.printf("%s, %s\n", s, s.getDescription()); | ||
} | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
students/23K0120/23K0120-p04/src/main/java/ru/mirea/practice/s23k0120/seasons/Seasons.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,85 @@ | ||
package ru.mirea.practice.s23k0120.seasons; | ||
|
||
public enum Seasons { | ||
SUMMER(25f), | ||
AUTUMN(5f), | ||
WINTER(-10f), | ||
SPRING(15f); | ||
|
||
private final float temperature; | ||
|
||
Seasons(float temperature) { | ||
this.temperature = temperature; | ||
} | ||
|
||
public float getTemperature() { | ||
return temperature; | ||
} | ||
|
||
public static void like(Seasons season) { | ||
String seasonStr; | ||
switch (season) { | ||
case SUMMER: | ||
seasonStr = "лето"; | ||
break; | ||
case SPRING: | ||
seasonStr = "весну"; | ||
break; | ||
case AUTUMN: | ||
seasonStr = "осень"; | ||
break; | ||
case WINTER: | ||
seasonStr = "зиму"; | ||
break; | ||
default: | ||
seasonStr = "-"; | ||
break; | ||
} | ||
System.out.printf("Я люблю %s\n", seasonStr); | ||
} | ||
|
||
public String getDescription() { | ||
String season; | ||
switch (this) { | ||
case SUMMER: | ||
season = "Тёплое"; | ||
break; | ||
case SPRING: | ||
season = "Умеренное"; | ||
break; | ||
case AUTUMN: | ||
season = "Прохладное"; | ||
break; | ||
case WINTER: | ||
season = "Холодное"; | ||
break; | ||
default: | ||
season = "-"; | ||
break; | ||
} | ||
return String.format("%s время года", season); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
String season; | ||
switch (this) { | ||
case SUMMER: | ||
season = "Лето"; | ||
break; | ||
case SPRING: | ||
season = "Весна"; | ||
break; | ||
case AUTUMN: | ||
season = "Осень"; | ||
break; | ||
case WINTER: | ||
season = "Зима"; | ||
break; | ||
default: | ||
season = "-"; | ||
break; | ||
} | ||
return String.format("Время года - %s, Средняя температура - %.2f°C", season, this.temperature); | ||
} | ||
} |
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,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<artifactId>23K0120</artifactId> | ||
<groupId>ru.mirea.practice</groupId> | ||
<version>2024.1</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>23K0120-p04_1</artifactId> | ||
<description>Наследование и Абстракция</description> | ||
</project> |
12 changes: 12 additions & 0 deletions
12
students/23K0120/23K0120-p04_1/src/main/java/ru/mirea/practice/s23k0120/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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ru.mirea.practice.s23k0120; | ||
|
||
public final class Main { | ||
|
||
private Main() { | ||
|
||
} | ||
|
||
public static void main(String[] args) { | ||
System.out.println("Четвёртая практическая работа! - часть 2"); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...ents/23K0120/23K0120-p04_1/src/main/java/ru/mirea/practice/s23k0120/exercise1/Circle.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,41 @@ | ||
package ru.mirea.practice.s23k0120.exercise1; | ||
|
||
public class Circle extends Shape { | ||
double radius; | ||
|
||
public Circle() { | ||
// Default constructor | ||
} | ||
|
||
public Circle(double radius) { | ||
this.radius = radius; | ||
} | ||
|
||
public Circle(double radius, String color, boolean filled) { | ||
super(color, filled); | ||
this.radius = radius; | ||
} | ||
|
||
public double getRadius() { | ||
return radius; | ||
} | ||
|
||
public void setRadius(float radius) { | ||
this.radius = radius; | ||
} | ||
|
||
@Override | ||
public double getPerimeter() { | ||
return radius * Math.PI * 2; | ||
} | ||
|
||
@Override | ||
public double getArea() { | ||
return radius * radius * Math.PI; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Circle{" + "radius=" + radius + ", color='" + color + '\'' + ", filled=" + filled + '}'; | ||
} | ||
} |
Oops, something went wrong.
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.
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.
проверка странная, зачем приводить к
int
?