Skip to content

Commit 13bf52b

Browse files
authored
Merge pull request BasePractice#130 from Timmmmofey/features/lab4
Features/lab4
2 parents ae3cb82 + 1fc54cb commit 13bf52b

File tree

10 files changed

+250
-0
lines changed

10 files changed

+250
-0
lines changed
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>23K1302</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K1302-p04</artifactId>
12+
<description>Четвёртое задание</description>
13+
</project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
enum Brand {
4+
HUAWEI, HP, LENOVO, APPLE, ASUS
5+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
4+
class Computer {
5+
private Brand brand;
6+
private Processor processor;
7+
private Memory memory;
8+
private Monitor monitor;
9+
10+
public Computer(Brand brand, Processor processor, Memory memory, Monitor monitor) {
11+
this.brand = brand;
12+
this.processor = processor;
13+
this.memory = memory;
14+
this.monitor = monitor;
15+
}
16+
17+
public Brand getBrand() {
18+
return brand;
19+
}
20+
21+
public Processor getProcessor() {
22+
return processor;
23+
}
24+
25+
public Memory getMemory() {
26+
return memory;
27+
}
28+
29+
public Monitor getMonitor() {
30+
return monitor;
31+
}
32+
33+
@Override
34+
public String toString() {
35+
return "Computer{"
36+
+ "brand=" + brand
37+
+ ", processor=" + processor
38+
+ ", memory=" + memory
39+
+ ", monitor=" + monitor
40+
+ '}';
41+
}
42+
}
43+
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
enum Ex1 {
4+
WINTER(-10) {
5+
@Override
6+
public String getDescription() {
7+
return "Холодное время года";
8+
}
9+
},
10+
SPRING(10) {
11+
@Override
12+
public String getDescription() {
13+
return "Прохладное время года";
14+
}
15+
},
16+
SUMMER(25) {
17+
@Override
18+
public String getDescription() {
19+
return "Теплое время года";
20+
}
21+
},
22+
AUTUMN(5) {
23+
@Override
24+
public String getDescription() {
25+
return "Прохладное время года";
26+
}
27+
};
28+
29+
private int averageTemperature;
30+
31+
Ex1(int averageTemperature) {
32+
this.averageTemperature = averageTemperature;
33+
}
34+
35+
public String getDescription() {
36+
return "Холодное время года";
37+
}
38+
39+
public int getAverageTemperature() {
40+
return averageTemperature;
41+
}
42+
43+
public static void main(String[] args) {
44+
Ex1 favoriteSeason = Ex1.AUTUMN;
45+
System.out.println("Мое любимое время года:");
46+
System.out.println("Название: " + favoriteSeason);
47+
System.out.println("Средняя температура: " + favoriteSeason.getAverageTemperature());
48+
System.out.println("Описание: " + favoriteSeason.getDescription());
49+
50+
printSeasonMessage(favoriteSeason);
51+
52+
for (Ex1 season : Ex1.values()) {
53+
System.out.println(season + ": Средняя температура = " + season.getAverageTemperature()
54+
+ ", Описание = " + season.getDescription());
55+
}
56+
}
57+
58+
public static void printSeasonMessage(Ex1 season) {
59+
switch (season) {
60+
case WINTER:
61+
System.out.println("Я люблю зиму");
62+
break;
63+
case SPRING:
64+
System.out.println("Я люблю весну");
65+
break;
66+
case SUMMER:
67+
System.out.println("Я люблю лето");
68+
break;
69+
case AUTUMN:
70+
System.out.println("Я люблю осень");
71+
break;
72+
default:
73+
System.out.println("Неизвестное время года");
74+
break;
75+
}
76+
}
77+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
public final class Ex4 {
4+
5+
private Ex4() {
6+
// Пустота
7+
}
8+
9+
public static void main(String[] args) {
10+
Processor processor = new Processor("Apple M2 Pro", 16, 3.5);
11+
Memory memory = new Memory("LPDDR5", 16);
12+
Monitor monitor = new Monitor("3456x2234 Retina", 16);
13+
14+
Computer computer = new Computer(Brand.APPLE, processor, memory, monitor);
15+
16+
System.out.println(computer);
17+
}
18+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
public class Main {
4+
5+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
class Memory {
4+
private String type;
5+
private int size;
6+
7+
public Memory(String type, int size) {
8+
this.type = type;
9+
this.size = size;
10+
}
11+
12+
public String getType() {
13+
return type;
14+
}
15+
16+
public int getSize() {
17+
return size;
18+
}
19+
20+
@Override
21+
public String toString() {
22+
return "Memory{"
23+
+ "type='" + type + '\''
24+
+ ", size=" + size + " GB"
25+
+ '}';
26+
}
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
class Monitor {
4+
private String resolution;
5+
private double size;
6+
7+
public Monitor(String resolution, double size) {
8+
this.resolution = resolution;
9+
this.size = size;
10+
}
11+
12+
public String getResolution() {
13+
return resolution;
14+
}
15+
16+
public double getSize() {
17+
return size;
18+
}
19+
20+
@Override
21+
public String toString() {
22+
return "Monitor{"
23+
+ "resolution='" + resolution + '\''
24+
+ ", size=" + size + " inches"
25+
+ '}';
26+
}
27+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
class Processor {
4+
private String model;
5+
private int cores;
6+
private double frequency;
7+
8+
public Processor(String model, int cores, double frequency) {
9+
this.model = model;
10+
this.cores = cores;
11+
this.frequency = frequency;
12+
}
13+
14+
public String getModel() {
15+
return model;
16+
}
17+
18+
public int getCores() {
19+
return cores;
20+
}
21+
22+
public double getFrequency() {
23+
return frequency;
24+
}
25+
26+
@Override
27+
public String toString() {
28+
return "Processor{"
29+
+ "model='" + model + '\''
30+
+ ", cores=" + cores
31+
+ ", frequency=" + frequency + " GHz"
32+
+ '}';
33+
}
34+
}

students/23K1302/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
<module>23K1302-p01</module>
1717
<module>23K1302-p02</module>
1818
<module>23K1302-p03</module>
19+
<module>23K1302-p04</module>
1920
</modules>
2021
</project>

0 commit comments

Comments
 (0)