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

Commit ec989f7

Browse files
authored
Merge pull request #537 from nickSavr/features/labs11-20
Лабораторные 11-20
2 parents 23643bf + 52ca2cf commit ec989f7

File tree

38 files changed

+762
-0
lines changed

38 files changed

+762
-0
lines changed

students/23K0186/23K0186-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="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>23K0186</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0186-p11</artifactId>
12+
<description>Массивы</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.s23k0089;
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: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package ru.mirea.practice.s23k0089.task2;
2+
3+
import java.text.SimpleDateFormat;
4+
import java.util.Calendar;
5+
import java.util.Scanner;
6+
7+
public abstract class Main {
8+
public static void main(String[] args) {
9+
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy MMMM dd HH:mm:ss");
10+
11+
Calendar nowDate = Calendar.getInstance();
12+
Calendar enterDate = Calendar.getInstance();
13+
14+
try (Scanner scanner = new Scanner(System.in)) {
15+
16+
System.out.println("Введите дату в формате |год месяц день| (пример: 2024 01 01)");
17+
enterDate.set(scanner.nextInt(), scanner.nextInt() - 1, scanner.nextInt());
18+
19+
System.out.println("Введите час в формате |часы| (пример: 13)");
20+
enterDate.set(Calendar.HOUR_OF_DAY, scanner.nextInt());
21+
22+
System.out.println("Введите минуту в формате |минуты| (пример: 45)");
23+
enterDate.set(Calendar.MINUTE, scanner.nextInt());
24+
25+
System.out.println("Введите секунду в формате |секунды| (пример: 30)");
26+
enterDate.set(Calendar.SECOND, scanner.nextInt());
27+
28+
int difYear = Math.abs(nowDate.get(Calendar.YEAR) - enterDate.get(Calendar.YEAR));
29+
int difMonth = Math.abs(nowDate.get(Calendar.MONTH) - enterDate.get(Calendar.MONTH));
30+
int difDay = Math.abs(nowDate.get(Calendar.DAY_OF_MONTH) - enterDate.get(Calendar.DAY_OF_MONTH));
31+
int difHour = Math.abs(nowDate.get(Calendar.HOUR_OF_DAY) - enterDate.get(Calendar.HOUR_OF_DAY));
32+
int difMinutes = Math.abs(nowDate.get(Calendar.MINUTE) - enterDate.get(Calendar.MINUTE));
33+
int difSeconds = Math.abs(nowDate.get(Calendar.SECOND) - enterDate.get(Calendar.SECOND));
34+
35+
System.out.println("Введённое время: " + sdf.format(enterDate.getTime()));
36+
System.out.printf("Разница:\nГоды = %d\nМесяца = %d\nДни = %d\nЧасы, минуты и секунды = %d:%d:%d", difYear,
37+
difMonth, difDay, difHour, difMinutes, difSeconds);
38+
39+
} catch (RuntimeException e) {
40+
throw new RuntimeException(e);
41+
}
42+
}
43+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package ru.mirea.practice.s23k0089.task5;
2+
3+
public abstract class CallMeLater {
4+
5+
public static String formatPhoneNumber(String phoneNumber) {
6+
String countryCode;
7+
String formattedNumber;
8+
9+
if (phoneNumber.startsWith("+")) {
10+
countryCode = phoneNumber.substring(1, phoneNumber.length() - 10);
11+
formattedNumber = phoneNumber.substring(phoneNumber.length() - 10);
12+
} else {
13+
countryCode = "7";
14+
formattedNumber = phoneNumber.substring(1);
15+
}
16+
17+
String areaCode = formattedNumber.substring(0, 3);
18+
String middlePart = formattedNumber.substring(3, 6);
19+
String lastFourNumeral = formattedNumber.substring(6);
20+
21+
return "+" + countryCode + areaCode + "-" + middlePart + "-" + lastFourNumeral;
22+
}
23+
24+
public static void main(String[] args) {
25+
String phoneNumber1 = "+79175655655";
26+
String phoneNumber2 = "89175655655";
27+
28+
System.out.println("Отформатированный номер 1: " + formatPhoneNumber(phoneNumber1));
29+
System.out.println("Отформатированный номер 2: " + formatPhoneNumber(phoneNumber2));
30+
}
31+
}

students/23K0186/23K0186-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="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>23K0186</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0186-p12</artifactId>
12+
<description>Массивы</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.s23k0089;
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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package ru.mirea.practice.s23k0089.task1;
2+
3+
public class Circle extends Shape {
4+
float radius;
5+
6+
public Circle(String color, int x, int y, float radius) {
7+
super(color,x,y);
8+
this.radius = radius;
9+
}
10+
11+
@Override
12+
public float getPerimeter() {
13+
return (float) (radius * Math.PI * 2);
14+
}
15+
16+
@Override
17+
public float getArea() {
18+
return (float) (radius * radius * Math.PI);
19+
}
20+
21+
@Override
22+
public String toString() {
23+
return "Circle{radius = " + radius + '}';
24+
}
25+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package ru.mirea.practice.s23k0089.task1;
2+
3+
public class Rectangle extends Shape {
4+
private float width;
5+
private float height;
6+
7+
public Rectangle(String color, int x, int y, float width, float height) {
8+
super(color, x, y);
9+
this.width = width;
10+
this.height = height;
11+
}
12+
13+
public double getWidth() {
14+
return width;
15+
}
16+
17+
public void setWidth(float width) {
18+
this.width = width;
19+
}
20+
21+
public double getHeight() {
22+
return height;
23+
}
24+
25+
public void setHeight(float height) {
26+
this.height = height;
27+
}
28+
29+
@Override
30+
public float getArea() {
31+
return width * height;
32+
}
33+
34+
@Override
35+
public float getPerimeter() {
36+
return 2 * (width + height);
37+
}
38+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package ru.mirea.practice.s23k0089.task1;
2+
3+
abstract class Shape {
4+
private String color;
5+
private int x;
6+
private int y;
7+
8+
public Shape(String color, int x, int y) {
9+
this.color = color;
10+
this.x = x;
11+
this.y = y;
12+
}
13+
14+
public String getColor() {
15+
return color;
16+
}
17+
18+
public void setColor(String color) {
19+
this.color = color;
20+
}
21+
22+
public int getX() {
23+
return x;
24+
}
25+
26+
public void setX(int x) {
27+
this.x = x;
28+
}
29+
30+
public int getY() {
31+
return y;
32+
}
33+
34+
public void setY(int y) {
35+
this.y = y;
36+
}
37+
38+
public abstract float getArea();
39+
40+
public abstract float getPerimeter();
41+
}
42+

students/23K0186/23K0186-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="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>23K0186</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0186-p13</artifactId>
12+
<description>Массивы</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.s23k0089;
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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package ru.mirea.practice.s23k0089.task1;
2+
3+
import java.util.Locale;
4+
5+
public abstract class Main {
6+
7+
public static void main(String[] args) {
8+
String input = "I like Java!!!";
9+
10+
char lastChar = input.charAt(input.length() - 1);
11+
System.out.println("Последний символ: " + lastChar);
12+
13+
boolean endsWithExclamation = input.endsWith("!!!");
14+
System.out.println("Заканчивается ли '!!!': " + endsWithExclamation);
15+
16+
boolean startsWithILike = input.startsWith("I like");
17+
System.out.println("Начинается на 'I like': " + startsWithILike);
18+
19+
boolean containsJava = input.contains("Java");
20+
System.out.println("Содержит 'Java': " + containsJava);
21+
22+
int javaPosition = input.indexOf("Java");
23+
System.out.println("Позиция 'Java': " + javaPosition);
24+
25+
String replacedString = input.replace('a', 'о');
26+
System.out.println("Замена 'а' на 'о': " + replacedString);
27+
28+
String upperCaseString = input.toUpperCase(Locale.getDefault());
29+
System.out.println("Верхний регистр: " + upperCaseString);
30+
31+
String lowerCaseString = input.toLowerCase(Locale.getDefault());
32+
System.out.println("Нижний регистр: " + lowerCaseString);
33+
34+
String substringJava = input.substring(javaPosition, javaPosition + "Java".length());
35+
System.out.println("Вырезанная строка: " + substringJava);
36+
}
37+
}

students/23K0186/23K0186-p14/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>23K0186</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0186-p14</artifactId>
12+
<description>Массивы</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.s23k0089;
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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package ru.mirea.practice.s23k0089.task2;
2+
3+
import java.util.Scanner;
4+
import java.util.regex.Pattern;
5+
import java.util.regex.Matcher;
6+
7+
public abstract class Main {
8+
public static void main(String[] args) {
9+
try (Scanner scanner = new Scanner(System.in)) {
10+
Pattern pattern = Pattern.compile("abcdefghijklmnopqrstuv18340");
11+
12+
System.out.print("Введите выражение: ");
13+
Matcher matcher = pattern.matcher(scanner.nextLine());
14+
boolean res = matcher.matches();
15+
if (res) {
16+
System.out.println("Выражение совпало");
17+
} else {
18+
System.out.print("Выражение отличается");
19+
}
20+
} catch (RuntimeException e) {
21+
throw new RuntimeException(e);
22+
}
23+
}
24+
}

students/23K0186/23K0186-p15/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>23K0186</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0186-p15</artifactId>
12+
<description>Массивы</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.s23k0089;
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+
}

0 commit comments

Comments
 (0)