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

Commit 3da11c9

Browse files
committed
Лабораторная 11-20
1 parent 1cdff3d commit 3da11c9

File tree

48 files changed

+1436
-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.

48 files changed

+1436
-0
lines changed

students/23K0140/23K0140-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>23K0140</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0140-p11</artifactId>
12+
<description>Лабораторная 11</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.s23k0140.task1;
2+
3+
import java.util.Date;
4+
5+
public final class Main {
6+
7+
private Main() {
8+
9+
}
10+
11+
public static void main(String[] args) {
12+
String developerLastName = "Иванов";
13+
String assignmentReceivedDate = "2024-09-28 10:00:00";
14+
Date currentDate = new Date();
15+
System.out.println("Фамилия разработчика: " + developerLastName);
16+
System.out.println("Дата и время получения задания: " + assignmentReceivedDate);
17+
System.out.println("Дата и время сдачи задания: " + currentDate);
18+
}
19+
20+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package ru.mirea.practice.s23k0140.task2;
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 Main {
9+
10+
private Main() {
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.s23k0140.task4;
2+
3+
import java.util.Calendar;
4+
import java.util.Date;
5+
import java.util.Scanner;
6+
7+
public final class Main {
8+
9+
private Main() {
10+
11+
}
12+
13+
public static void main(String[] args) {
14+
15+
try (Scanner scanner = new Scanner(System.in)) {
16+
System.out.print("Введите год: ");
17+
final int year = scanner.nextInt();
18+
19+
System.out.print("Введите месяц: ");
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("Введите день: ");
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("Введите часы: ");
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("Введите минуты: ");
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/23K0140/23K0140-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>23K0140</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0140-p12</artifactId>
12+
<description>Лабораторная 12</description>
13+
</project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package ru.mirea.practice.s23k0140.task1;
2+
3+
public class Circle extends Shape {
4+
5+
public Circle(double x, double y, String color) {
6+
super(x, y, color);
7+
}
8+
9+
@Override
10+
public String toString() {
11+
return "Square{" + super.toString() + "}";
12+
}
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package ru.mirea.practice.s23k0140.task1;
2+
3+
public final class Main {
4+
5+
private Main() {
6+
}
7+
8+
public static void main(String[] args) {
9+
Square square = new Square(2.0, 1.0, "green");
10+
Square circle = new Square(2.0, 1.0, "yellow");
11+
System.out.println(square);
12+
System.out.println(circle);
13+
}
14+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package ru.mirea.practice.s23k0140.task1;
2+
3+
public abstract class Shape {
4+
5+
private double x;
6+
private double y;
7+
private String color;
8+
9+
public Shape(double x, double y, String color) {
10+
this.x = x;
11+
this.y = y;
12+
this.color = color;
13+
}
14+
15+
public double getX() {
16+
return x;
17+
}
18+
19+
public double getY() {
20+
return y;
21+
}
22+
23+
public String getColor() {
24+
return color;
25+
}
26+
27+
@Override
28+
public String toString() {
29+
return "Shape{"
30+
+ "x='" + x + '\''
31+
+ ", y='" + y + '\''
32+
+ ", color='" + color + '\''
33+
+ '}';
34+
}
35+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package ru.mirea.practice.s23k0140.task1;
2+
3+
public class Square extends Shape {
4+
5+
public Square(double x, double y, String color) {
6+
super(x, y, color);
7+
}
8+
9+
@Override
10+
public String toString() {
11+
return "Square{" + super.toString() + "}";
12+
}
13+
}

students/23K0140/23K0140-p13/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>23K0140</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0140-p13</artifactId>
12+
<description>Лабораторная 13</description>
13+
</project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package ru.mirea.practice.s23k0140.task1;
2+
3+
import java.util.Locale;
4+
5+
public abstract class Main {
6+
public static Locale ru_Ru = new Locale("ru", "Ru");
7+
8+
public static void stringMethod(String s) {
9+
System.out.println(s.charAt(s.length() - 1));
10+
System.out.println(s.endsWith("!!!"));
11+
System.out.println(s.startsWith("I like"));
12+
System.out.println(s.contains("Java"));
13+
System.out.println(s.lastIndexOf("Java"));
14+
String s1 = s.replace("a", "o");
15+
System.out.println(s1);
16+
String s2 = s1.toUpperCase(ru_Ru);
17+
System.out.println(s2);
18+
String s3 = s2.toLowerCase(ru_Ru);
19+
System.out.println(s3);
20+
String s4 = s.substring(s.lastIndexOf("Java"), s.indexOf("!"));
21+
System.out.println(s4);
22+
}
23+
24+
public static void main(String[] args) {
25+
stringMethod("I like Java!!!");
26+
}
27+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package ru.mirea.practice.s23k0140.task2;
2+
3+
public final class Main {
4+
private Main() {
5+
6+
}
7+
8+
public static void main(String[] args) {
9+
Person person1 = new Person("Иванов", "Иван", "Иванович");
10+
Person person2 = new Person("Петров", "Петр", null);
11+
Person person3 = new Person("Сидоров", null, "Сидорович");
12+
Person person4 = new Person("Кузнецов", null, null);
13+
14+
System.out.println(person1.getFullName());
15+
System.out.println(person2.getFullName());
16+
System.out.println(person3.getFullName());
17+
System.out.println(person4.getFullName());
18+
}
19+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package ru.mirea.practice.s23k0140.task2;
2+
3+
public class Person {
4+
private String lastName;
5+
private String firstName;
6+
private String middleName;
7+
8+
9+
public Person(String lastName, String firstName, String middleName) {
10+
this.lastName = lastName;
11+
this.firstName = firstName;
12+
this.middleName = middleName;
13+
}
14+
15+
16+
public String getFullName() {
17+
StringBuilder fullName = new StringBuilder(lastName);
18+
if (firstName != null && !firstName.isEmpty()) {
19+
fullName.append(" ").append(firstName.charAt(0)).append(".");
20+
}
21+
if (middleName != null && !middleName.isEmpty()) {
22+
fullName.append(" ").append(middleName.charAt(0)).append(".");
23+
}
24+
25+
return fullName.toString();
26+
}
27+
28+
public String getLastName() {
29+
return lastName;
30+
}
31+
32+
public void setLastName(String lastName) {
33+
this.lastName = lastName;
34+
}
35+
36+
public String getFirstName() {
37+
return firstName;
38+
}
39+
40+
public void setFirstName(String firstName) {
41+
this.firstName = firstName;
42+
}
43+
44+
public String getMiddleName() {
45+
return middleName;
46+
}
47+
48+
public void setMiddleName(String middleName) {
49+
this.middleName = middleName;
50+
}
51+
52+
}

0 commit comments

Comments
 (0)