Skip to content

Commit

Permalink
Merge pull request #537 from nickSavr/features/labs11-20
Browse files Browse the repository at this point in the history
Лабораторные 11-20
  • Loading branch information
Pastor authored Nov 8, 2024
2 parents 23643bf + 52ca2cf commit ec989f7
Show file tree
Hide file tree
Showing 38 changed files with 762 additions and 0 deletions.
13 changes: 13 additions & 0 deletions students/23K0186/23K0186-p11/pom.xml
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>23K0186</artifactId>
<groupId>ru.mirea.practice</groupId>
<version>2024.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>23K0186-p11</artifactId>
<description>Массивы</description>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ru.mirea.practice.s23k0089;

public final class Main {

private Main() {

}

public static void main(String[] args) {
System.out.println("первая практическая работа!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package ru.mirea.practice.s23k0089.task2;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Scanner;

public abstract class Main {
public static void main(String[] args) {
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy MMMM dd HH:mm:ss");

Calendar nowDate = Calendar.getInstance();
Calendar enterDate = Calendar.getInstance();

try (Scanner scanner = new Scanner(System.in)) {

System.out.println("Введите дату в формате |год месяц день| (пример: 2024 01 01)");
enterDate.set(scanner.nextInt(), scanner.nextInt() - 1, scanner.nextInt());

System.out.println("Введите час в формате |часы| (пример: 13)");
enterDate.set(Calendar.HOUR_OF_DAY, scanner.nextInt());

System.out.println("Введите минуту в формате |минуты| (пример: 45)");
enterDate.set(Calendar.MINUTE, scanner.nextInt());

System.out.println("Введите секунду в формате |секунды| (пример: 30)");
enterDate.set(Calendar.SECOND, scanner.nextInt());

int difYear = Math.abs(nowDate.get(Calendar.YEAR) - enterDate.get(Calendar.YEAR));
int difMonth = Math.abs(nowDate.get(Calendar.MONTH) - enterDate.get(Calendar.MONTH));
int difDay = Math.abs(nowDate.get(Calendar.DAY_OF_MONTH) - enterDate.get(Calendar.DAY_OF_MONTH));
int difHour = Math.abs(nowDate.get(Calendar.HOUR_OF_DAY) - enterDate.get(Calendar.HOUR_OF_DAY));
int difMinutes = Math.abs(nowDate.get(Calendar.MINUTE) - enterDate.get(Calendar.MINUTE));
int difSeconds = Math.abs(nowDate.get(Calendar.SECOND) - enterDate.get(Calendar.SECOND));

System.out.println("Введённое время: " + sdf.format(enterDate.getTime()));
System.out.printf("Разница:\nГоды = %d\nМесяца = %d\nДни = %d\nЧасы, минуты и секунды = %d:%d:%d", difYear,
difMonth, difDay, difHour, difMinutes, difSeconds);

} catch (RuntimeException e) {
throw new RuntimeException(e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package ru.mirea.practice.s23k0089.task5;

public abstract class CallMeLater {

public static String formatPhoneNumber(String phoneNumber) {
String countryCode;
String formattedNumber;

if (phoneNumber.startsWith("+")) {
countryCode = phoneNumber.substring(1, phoneNumber.length() - 10);
formattedNumber = phoneNumber.substring(phoneNumber.length() - 10);
} else {
countryCode = "7";
formattedNumber = phoneNumber.substring(1);
}

String areaCode = formattedNumber.substring(0, 3);
String middlePart = formattedNumber.substring(3, 6);
String lastFourNumeral = formattedNumber.substring(6);

return "+" + countryCode + areaCode + "-" + middlePart + "-" + lastFourNumeral;
}

public static void main(String[] args) {
String phoneNumber1 = "+79175655655";
String phoneNumber2 = "89175655655";

System.out.println("Отформатированный номер 1: " + formatPhoneNumber(phoneNumber1));
System.out.println("Отформатированный номер 2: " + formatPhoneNumber(phoneNumber2));
}
}
13 changes: 13 additions & 0 deletions students/23K0186/23K0186-p12/pom.xml
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>23K0186</artifactId>
<groupId>ru.mirea.practice</groupId>
<version>2024.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>23K0186-p12</artifactId>
<description>Массивы</description>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ru.mirea.practice.s23k0089;

public final class Main {

private Main() {

}

public static void main(String[] args) {
System.out.println("первая практическая работа!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package ru.mirea.practice.s23k0089.task1;

public class Circle extends Shape {
float radius;

public Circle(String color, int x, int y, float radius) {
super(color,x,y);
this.radius = radius;
}

@Override
public float getPerimeter() {
return (float) (radius * Math.PI * 2);
}

@Override
public float getArea() {
return (float) (radius * radius * Math.PI);
}

@Override
public String toString() {
return "Circle{radius = " + radius + '}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package ru.mirea.practice.s23k0089.task1;

public class Rectangle extends Shape {
private float width;
private float height;

public Rectangle(String color, int x, int y, float width, float height) {
super(color, x, y);
this.width = width;
this.height = height;
}

public double getWidth() {
return width;
}

public void setWidth(float width) {
this.width = width;
}

public double getHeight() {
return height;
}

public void setHeight(float height) {
this.height = height;
}

@Override
public float getArea() {
return width * height;
}

@Override
public float getPerimeter() {
return 2 * (width + height);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package ru.mirea.practice.s23k0089.task1;

abstract class Shape {
private String color;
private int x;
private int y;

public Shape(String color, int x, int y) {
this.color = color;
this.x = x;
this.y = y;
}

public String getColor() {
return color;
}

public void setColor(String color) {
this.color = color;
}

public int getX() {
return x;
}

public void setX(int x) {
this.x = x;
}

public int getY() {
return y;
}

public void setY(int y) {
this.y = y;
}

public abstract float getArea();

public abstract float getPerimeter();
}

13 changes: 13 additions & 0 deletions students/23K0186/23K0186-p13/pom.xml
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>23K0186</artifactId>
<groupId>ru.mirea.practice</groupId>
<version>2024.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>23K0186-p13</artifactId>
<description>Массивы</description>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ru.mirea.practice.s23k0089;

public final class Main {

private Main() {

}

public static void main(String[] args) {
System.out.println("первая практическая работа!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package ru.mirea.practice.s23k0089.task1;

import java.util.Locale;

public abstract class Main {

public static void main(String[] args) {
String input = "I like Java!!!";

char lastChar = input.charAt(input.length() - 1);
System.out.println("Последний символ: " + lastChar);

boolean endsWithExclamation = input.endsWith("!!!");
System.out.println("Заканчивается ли '!!!': " + endsWithExclamation);

boolean startsWithILike = input.startsWith("I like");
System.out.println("Начинается на 'I like': " + startsWithILike);

boolean containsJava = input.contains("Java");
System.out.println("Содержит 'Java': " + containsJava);

int javaPosition = input.indexOf("Java");
System.out.println("Позиция 'Java': " + javaPosition);

String replacedString = input.replace('a', 'о');
System.out.println("Замена 'а' на 'о': " + replacedString);

String upperCaseString = input.toUpperCase(Locale.getDefault());
System.out.println("Верхний регистр: " + upperCaseString);

String lowerCaseString = input.toLowerCase(Locale.getDefault());
System.out.println("Нижний регистр: " + lowerCaseString);

String substringJava = input.substring(javaPosition, javaPosition + "Java".length());
System.out.println("Вырезанная строка: " + substringJava);
}
}
13 changes: 13 additions & 0 deletions students/23K0186/23K0186-p14/pom.xml
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>23K0186</artifactId>
<groupId>ru.mirea.practice</groupId>
<version>2024.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>23K0186-p14</artifactId>
<description>Массивы</description>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ru.mirea.practice.s23k0089;

public final class Main {

private Main() {

}

public static void main(String[] args) {
System.out.println("первая практическая работа!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package ru.mirea.practice.s23k0089.task2;

import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

public abstract class Main {
public static void main(String[] args) {
try (Scanner scanner = new Scanner(System.in)) {
Pattern pattern = Pattern.compile("abcdefghijklmnopqrstuv18340");

System.out.print("Введите выражение: ");
Matcher matcher = pattern.matcher(scanner.nextLine());
boolean res = matcher.matches();
if (res) {
System.out.println("Выражение совпало");
} else {
System.out.print("Выражение отличается");
}
} catch (RuntimeException e) {
throw new RuntimeException(e);
}
}
}
13 changes: 13 additions & 0 deletions students/23K0186/23K0186-p15/pom.xml
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>23K0186</artifactId>
<groupId>ru.mirea.practice</groupId>
<version>2024.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>23K0186-p15</artifactId>
<description>Массивы</description>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ru.mirea.practice.s23k0089;

public final class Main {

private Main() {

}

public static void main(String[] args) {
System.out.println("первая практическая работа!");
}
}
Loading

0 comments on commit ec989f7

Please sign in to comment.