-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #537 from nickSavr/features/labs11-20
Лабораторные 11-20
- Loading branch information
Showing
38 changed files
with
762 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
12 changes: 12 additions & 0 deletions
12
students/23K0186/23K0186-p11/src/main/java/ru/mirea/practice/s23k0186/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("первая практическая работа!"); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
students/23K0186/23K0186-p11/src/main/java/ru/mirea/practice/s23k0186/task2/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
students/23K0186/23K0186-p11/src/main/java/ru/mirea/practice/s23k0186/task5/CallMeLater.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
12 changes: 12 additions & 0 deletions
12
students/23K0186/23K0186-p12/src/main/java/ru/mirea/practice/s23k0186/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("первая практическая работа!"); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
students/23K0186/23K0186-p12/src/main/java/ru/mirea/practice/s23k0186/task1/Circle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 + '}'; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
students/23K0186/23K0186-p12/src/main/java/ru/mirea/practice/s23k0186/task1/Rectangle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
students/23K0186/23K0186-p12/src/main/java/ru/mirea/practice/s23k0186/task1/Shape.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
12 changes: 12 additions & 0 deletions
12
students/23K0186/23K0186-p13/src/main/java/ru/mirea/practice/s23k0186/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("первая практическая работа!"); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
students/23K0186/23K0186-p13/src/main/java/ru/mirea/practice/s23k0186/task1/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
12 changes: 12 additions & 0 deletions
12
students/23K0186/23K0186-p14/src/main/java/ru/mirea/practice/s23k0186/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("первая практическая работа!"); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
students/23K0186/23K0186-p14/src/main/java/ru/mirea/practice/s23k0186/task2/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
12 changes: 12 additions & 0 deletions
12
students/23K0186/23K0186-p15/src/main/java/ru/mirea/practice/s23k0186/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("первая практическая работа!"); | ||
} | ||
} |
Oops, something went wrong.