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

Commit d97b03a

Browse files
committed
Лабораторная 11-20
1 parent 47756b3 commit d97b03a

File tree

61 files changed

+1655
-0
lines changed

Some content is hidden

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

61 files changed

+1655
-0
lines changed

students/23K0145/23K0145-p11/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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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>23K0145</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0145-p11</artifactId>
12+
<description>11 практика</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.s23k0145;
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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package ru.mirea.practice.s23k0145;
2+
3+
import java.util.Date;
4+
5+
public final class Num1 {
6+
7+
private Num1() {
8+
9+
}
10+
11+
public static void main(String[] args) {
12+
String developerSurname = "Иванов";
13+
14+
Date receivedDate = new Date();
15+
16+
try {
17+
Thread.sleep(5000);
18+
} catch (InterruptedException e) {
19+
System.out.println("Процесс был прерван.");
20+
}
21+
22+
Date submittedDate = new Date();
23+
24+
System.out.println("Фамилия разработчика: " + developerSurname);
25+
System.out.println("Дата и время получения задания: " + receivedDate);
26+
System.out.println("Дата и время сдачи задания: " + submittedDate);
27+
}
28+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package ru.mirea.practice.s23k0145;
2+
3+
import java.text.ParseException;
4+
import java.text.SimpleDateFormat;
5+
import java.util.Date;
6+
import java.util.Scanner;
7+
8+
public final class Num2 {
9+
10+
private Num2() {
11+
12+
}
13+
14+
public static void main(String[] args) {
15+
16+
try (Scanner scanner = new Scanner(System.in)) {
17+
18+
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
19+
dateFormat.setLenient(false);
20+
21+
System.out.println("Введите дату и время в формате dd.MM.yyyy HH:mm:ss:");
22+
String userInput = scanner.nextLine();
23+
24+
try {
25+
Date userDate = dateFormat.parse(userInput);
26+
27+
Date currentDate = new Date();
28+
29+
System.out.println("Введённая дата и время: " + dateFormat.format(userDate));
30+
System.out.println("Текущая дата и время: " + dateFormat.format(currentDate));
31+
32+
if (userDate.before(currentDate)) {
33+
System.out.println("Введённая дата и время раньше текущей системной даты.");
34+
} else if (userDate.after(currentDate)) {
35+
System.out.println("Введённая дата и время позже текущей системной даты.");
36+
} else {
37+
System.out.println("Введённая дата и время совпадают с текущей системной датой.");
38+
}
39+
40+
} catch (ParseException e) {
41+
System.out.println("Ошибка: Неверный формат даты. Пожалуйста, следуйте формату dd.MM.yyyy HH:mm:ss.");
42+
} finally {
43+
scanner.close();
44+
}
45+
}
46+
}
47+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package ru.mirea.practice.s23k0145;
2+
3+
import java.util.Calendar;
4+
import java.util.Date;
5+
import java.util.Scanner;
6+
7+
public final class Num4 {
8+
9+
private Num4() {
10+
11+
}
12+
13+
public static void main(String[] args) {
14+
15+
try (Scanner scanner = new Scanner(System.in)) {
16+
System.out.print("Введите год (например, 2023): ");
17+
final int year = scanner.nextInt();
18+
19+
System.out.print("Введите месяц (1-12): ");
20+
final int month = scanner.nextInt();
21+
if (month < 1 || month > 12) {
22+
System.out.println("Ошибка: Месяц должен быть в диапазоне от 1 до 12.");
23+
return;
24+
}
25+
26+
System.out.print("Введите день (1-31): ");
27+
final int day = scanner.nextInt();
28+
if (day < 1 || day > 31) {
29+
System.out.println("Ошибка: День должен быть в диапазоне от 1 до 31.");
30+
return;
31+
}
32+
33+
System.out.print("Введите часы (0-23): ");
34+
final int hour = scanner.nextInt();
35+
if (hour < 0 || hour > 23) {
36+
System.out.println("Ошибка: Часы должны быть в диапазоне от 0 до 23.");
37+
return;
38+
}
39+
40+
System.out.print("Введите минуты (0-59): ");
41+
final int minute = scanner.nextInt();
42+
if (minute < 0 || minute > 59) {
43+
System.out.println("Ошибка: Минуты должны быть в диапазоне от 0 до 59.");
44+
return;
45+
}
46+
47+
Calendar calendar = Calendar.getInstance();
48+
calendar.set(Calendar.YEAR, year);
49+
calendar.set(Calendar.MONTH, month - 1);
50+
calendar.set(Calendar.DAY_OF_MONTH, day);
51+
calendar.set(Calendar.HOUR_OF_DAY, hour);
52+
calendar.set(Calendar.MINUTE, minute);
53+
calendar.set(Calendar.SECOND, 0);
54+
calendar.set(Calendar.MILLISECOND, 0);
55+
56+
Date date = calendar.getTime();
57+
58+
System.out.println("\nСозданный объект Calendar:");
59+
System.out.println(calendar.getTime());
60+
61+
System.out.println("Созданный объект Date:");
62+
System.out.println(date);
63+
64+
Date currentDate = new Date();
65+
if (date.before(currentDate)) {
66+
System.out.println("Введённая дата и время ранее текущей системной даты.");
67+
} else if (date.after(currentDate)) {
68+
System.out.println("Введённая дата и время позже текущей системной даты.");
69+
} else {
70+
System.out.println("Введённая дата и время совпадают с текущей системной датой.");
71+
}
72+
73+
} catch (Exception e) {
74+
System.out.println("Ошибка ввода. Пожалуйста, вводите только числовые значения.");
75+
}
76+
}
77+
}

students/23K0145/23K0145-p12/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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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>23K0145</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0145-p12</artifactId>
12+
<description>12 практика</description>
13+
</project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package ru.mirea.practice.s23k0145;
2+
3+
public class Circle extends Shape {
4+
private double radius;
5+
6+
public Circle(String color, String position, double radius) {
7+
super(color, position);
8+
this.radius = radius;
9+
}
10+
11+
@Override
12+
public double area() {
13+
return Math.PI * radius * radius;
14+
}
15+
16+
@Override
17+
public double perimeter() {
18+
return 2 * Math.PI * radius;
19+
}
20+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package ru.mirea.practice.s23k0145;
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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package ru.mirea.practice.s23k0145;
2+
3+
public class Rectangle extends Shape {
4+
private double width; // Ширина прямоугольника
5+
private double height; // Высота прямоугольника
6+
7+
public Rectangle(String color, String position, double width, double height) {
8+
super(color, position);
9+
this.width = width;
10+
this.height = height;
11+
}
12+
13+
@Override
14+
public double area() {
15+
return width * height;
16+
}
17+
18+
@Override
19+
public double perimeter() {
20+
return 2 * (width + height);
21+
}
22+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package ru.mirea.practice.s23k0145;
2+
3+
public abstract class Shape {
4+
private String color;
5+
private String position;
6+
7+
public Shape(String color, String position) {
8+
this.color = color;
9+
this.position = position;
10+
}
11+
12+
public String getColor() {
13+
return color;
14+
}
15+
16+
public String getPosition() {
17+
return position;
18+
}
19+
20+
public abstract double area();
21+
22+
public abstract double perimeter();
23+
}

0 commit comments

Comments
 (0)