-
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.
- Loading branch information
egork
committed
Nov 2, 2024
1 parent
d9aeb9e
commit 20322d0
Showing
29 changed files
with
543 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>23K0563</artifactId> | ||
<groupId>ru.mirea.practice</groupId> | ||
<version>2024.1</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>23K0563-p11</artifactId> | ||
<description>11</description> | ||
</project> |
21 changes: 21 additions & 0 deletions
21
students/23K0563/23K0563-p11/src/main/java/mirea/lab11/Prac11p1.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,21 @@ | ||
package mirea.lab11; | ||
|
||
/* Написать программу, выводящую фамилию разработчика, дату и время | ||
получения задания, а также дату и время сдачи задания. Для получения | ||
последней даты и времени использовать класс Date из пакета java.util.* | ||
(Объявление Dated=newDate() или метод System.currentTimeMillis(). */ | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Calendar; | ||
import java.util.GregorianCalendar; | ||
|
||
public abstract class Prac11p1 { | ||
public static void main(String[] args) { | ||
SimpleDateFormat f = new SimpleDateFormat("EEEE, dd.MM.yyyy в HH:mm:ss"); | ||
Calendar rec = new GregorianCalendar(2024, Calendar.SEPTEMBER, 4, 9, 0, 0); | ||
Calendar out = Calendar.getInstance(); | ||
System.out.println("Разработчик: Сидоров"); | ||
System.out.println("Дата получения работы: " + f.format(rec.getTime())); | ||
System.out.println("Дата сдачи работы: " + f.format(out.getTime())); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
students/23K0563/23K0563-p11/src/main/java/mirea/lab11/Prac11p2.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,33 @@ | ||
package mirea.lab11; | ||
|
||
/* Приложение, сравнивающее текущую дату и дату, введенную | ||
пользователем c текущим системным временем */ | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Calendar; | ||
import java.util.Scanner; | ||
|
||
public abstract class Prac11p2 { | ||
public static void main(String[] args) { | ||
try (Scanner sc = new Scanner(System.in)) { | ||
SimpleDateFormat f = new SimpleDateFormat("dd.MM.yyyy"); | ||
System.out.print("\nВведите дату(dd.mm.yyyy): "); | ||
String inp = sc.nextLine(); | ||
Calendar user = Calendar.getInstance(); | ||
if (inp.length() == 10) { | ||
user.set(Calendar.DAY_OF_MONTH, Integer.parseInt(inp.substring(0, 2))); | ||
user.set(Calendar.MONTH, Integer.parseInt(inp.substring(3, 5)) - 1); | ||
user.set(Calendar.YEAR, Integer.parseInt(inp.substring(6))); | ||
Calendar now = Calendar.getInstance(); | ||
long u = user.getTimeInMillis(); | ||
long n = now.getTimeInMillis(); | ||
System.out.println("Разница между " + f.format(user.getTime()) + " и " + f.format(now.getTime()) | ||
+ " составляет " + (int) ((double) Math.abs(u - n) / 1000 / 60 / 60 / 24) + " дня."); | ||
} else { | ||
System.out.println("Неверный ввод даты"); | ||
System.exit(0); | ||
} | ||
|
||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
students/23K0563/23K0563-p11/src/main/java/mirea/lab11/Prac11p4.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,26 @@ | ||
package mirea.lab11; | ||
|
||
/* Напишите пользовательский код, который формирует объекты Date и | ||
Calendar по следующим данным, вводимым пользователем: | ||
<Год><Месяц><Число> | ||
<Часы1><минуты> */ | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Calendar; | ||
import java.util.Scanner; | ||
|
||
public abstract class Prac11p4 { | ||
public static void main(String[] args) { | ||
try (Scanner sc = new Scanner(System.in)) { | ||
System.out.println("Введите формат вывода даты\nИспользуйте <Год><Месяц><Число><Часы1><минуты>:"); | ||
String inp = sc.nextLine(); | ||
inp = inp.replace("<Год>", "yyyy"); | ||
inp = inp.replace("<Месяц>", "MM"); | ||
inp = inp.replace("<Число>", "dd"); | ||
inp = inp.replace("<Часы1>", "hh"); | ||
inp = inp.replace("<минуты>", "mm"); | ||
SimpleDateFormat f = new SimpleDateFormat(inp); | ||
System.out.println("Текущая дата:\n" + f.format(Calendar.getInstance().getTime())); | ||
} | ||
} | ||
} |
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>23K0563</artifactId> | ||
<groupId>ru.mirea.practice</groupId> | ||
<version>2024.1</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>23K0563-p13</artifactId> | ||
<description>13</description> | ||
</project> |
27 changes: 27 additions & 0 deletions
27
students/23K0563/23K0563-p13/src/main/java/mirea/lab13/Prac13p1.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,27 @@ | ||
package mirea.lab13; | ||
|
||
import java.util.Locale; | ||
import java.util.Scanner; | ||
|
||
public abstract class Prac13p1 { | ||
public static String p1(String s) { | ||
return s; | ||
} | ||
|
||
public static void main(String[] args) { | ||
try (Scanner sc = new Scanner(System.in)) { | ||
System.out.print("Введите строку: "); | ||
String s = sc.nextLine(); | ||
System.out.println("P1: " + p1(s)); | ||
System.out.println("P2: " + s.charAt(s.length() - 1)); | ||
System.out.println("P3: " + s.endsWith("!!!")); | ||
System.out.println("P4: " + s.startsWith("I like")); | ||
System.out.println("P5: " + s.contains("Java")); | ||
System.out.println("P6: " + s.lastIndexOf("Java")); | ||
System.out.println("P7: " + s.replace("a", "o")); | ||
System.out.println("P8: " + s.toUpperCase(Locale.getDefault())); | ||
System.out.println("P9: " + s.toLowerCase(Locale.getDefault())); | ||
System.out.println("P10: " + s.substring(s.lastIndexOf("Java"), s.lastIndexOf("Java") + 4)); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
students/23K0563/23K0563-p13/src/main/java/mirea/lab13/Prac13p5.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,19 @@ | ||
package mirea.lab13; | ||
|
||
public abstract class Prac13p5 { | ||
public static String phoneFormat(String p) { | ||
if (p.startsWith("8")) { | ||
p = p.replaceFirst("8", "+7"); | ||
} | ||
if (p.startsWith("+")) { | ||
return p.substring(0, 2) + " " + p.substring(2, 5) + "-" + p.substring(5, 8) + "-" + p.substring(8); | ||
} else { | ||
return " "; | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
System.out.println(phoneFormat("+71346644453")); | ||
System.out.println(phoneFormat("89653050013")); | ||
} | ||
} |
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>23K0563</artifactId> | ||
<groupId>ru.mirea.practice</groupId> | ||
<version>2024.1</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>23K0563-p14</artifactId> | ||
<description>14</description> | ||
</project> |
21 changes: 21 additions & 0 deletions
21
students/23K0563/23K0563-p14/src/main/java/mirea/lab14/Prac14p2.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,21 @@ | ||
package mirea.lab14; | ||
|
||
import java.util.Scanner; | ||
|
||
/* Написать регулярное выражение, определяющее является ли данная | ||
строка строкой "abcdefghijklmnopqrstuv18340" или нет. */ | ||
|
||
public abstract class Prac14p2 { | ||
public static void main(String[] args) { | ||
try (Scanner sc = new Scanner(System.in)) { | ||
String ex = "abcdefghijklmnopqrstuv18340"; | ||
System.out.print("Введите строку: "); | ||
String inp = sc.nextLine(); | ||
if (inp.matches(ex)) { | ||
System.out.println("Строка совпадает с " + ex); | ||
} else { | ||
System.out.println("Строка не совпадает с " + ex); | ||
} | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
students/23K0563/23K0563-p14/src/main/java/mirea/lab14/Prac14p3.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,22 @@ | ||
package mirea.lab14; | ||
|
||
import java.util.regex.Pattern; | ||
import java.util.regex.Matcher; | ||
import java.util.Scanner; | ||
|
||
/* Дан текст со списками цен. Извлечь из него цены в USD, RUВ, EU */ | ||
|
||
public abstract class Prac14p3 { | ||
public static void main(String[] args) { | ||
try (Scanner sc = new Scanner(System.in)) { | ||
|
||
Pattern p = Pattern.compile("(\\d+\\.\\d\\d ((USD)|(RUB)|(EU)))"); | ||
System.out.print("Введите строку: "); | ||
String inp = sc.nextLine(); | ||
Matcher m = p.matcher(inp); | ||
if (m.find()) { | ||
System.out.println(m.group(1)); | ||
} | ||
} | ||
} | ||
} |
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>23K0563</artifactId> | ||
<groupId>ru.mirea.practice</groupId> | ||
<version>2024.1</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>23K0563-p18</artifactId> | ||
<description>18</description> | ||
</project> |
11 changes: 11 additions & 0 deletions
11
students/23K0563/23K0563-p18/src/main/java/mirea/lab18/p1/Exception1.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,11 @@ | ||
package mirea.lab18.p1; | ||
|
||
public class Exception1 { | ||
public void exceptionDemo() { | ||
try { | ||
System.out.println(2.0 / 0.0); | ||
} catch (ArithmeticException e) { | ||
System.out.println("Attempted division by zero"); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
students/23K0563/23K0563-p18/src/main/java/mirea/lab18/p1/Prac18p1.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 mirea.lab18.p1; | ||
|
||
public abstract class Prac18p1 { | ||
public static void main(String[] args) { | ||
new Exception1().exceptionDemo(); | ||
} | ||
} | ||
|
||
/* | ||
* При делении целого числа на ноль вызывается исключение ArithmeticException | ||
* При делении числа с плавующей точкой на ноль возвращается Infinity | ||
* */ |
20 changes: 20 additions & 0 deletions
20
students/23K0563/23K0563-p18/src/main/java/mirea/lab18/p2/Exception2.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,20 @@ | ||
package mirea.lab18.p2; | ||
|
||
import java.util.Scanner; | ||
|
||
public class Exception2 { | ||
public void exceptionDemo() { | ||
try (Scanner myScanner = new Scanner(System.in)) { | ||
System.out.print("Enter an integer "); | ||
String intString = myScanner.next(); | ||
try { | ||
int i = Integer.parseInt(intString); | ||
System.out.println(2 / i); | ||
} catch (NumberFormatException e) { | ||
System.out.println("Input is not an integer!"); | ||
} catch (ArithmeticException e) { | ||
System.out.println("Division by zero!"); | ||
} | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
students/23K0563/23K0563-p18/src/main/java/mirea/lab18/p2/Prac18p2.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,14 @@ | ||
package mirea.lab18.p2; | ||
|
||
public abstract class Prac18p2 { | ||
public static void main(String[] args) { | ||
new Exception2().exceptionDemo(); | ||
} | ||
} | ||
|
||
/* | ||
* При вводе qwerty: NumberFormatException, невозможно преобразовать строку qwerty в Int | ||
* При вводе 0: ArithmeticException, попытка деления на 0 | ||
* При вводе 1.2: NumberFormatException невозможно преобразовать 1.2 в Int | ||
* При вводе 1: Нет ошибок | ||
* */ |
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>23K0563</artifactId> | ||
<groupId>ru.mirea.practice</groupId> | ||
<version>2024.1</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>23K0563-p19</artifactId> | ||
<description>19</description> | ||
</project> |
7 changes: 7 additions & 0 deletions
7
students/23K0563/23K0563-p19/src/main/java/mirea/lab19/p1/InnException.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,7 @@ | ||
package mirea.lab19.p1; | ||
|
||
public class InnException extends RuntimeException { | ||
public InnException(String message) { | ||
super(message); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
students/23K0563/23K0563-p19/src/main/java/mirea/lab19/p1/Prac19p1.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,18 @@ | ||
package mirea.lab19.p1; | ||
|
||
import java.util.Scanner; | ||
|
||
public abstract class Prac19p1 { | ||
public static void main(String[] args) { | ||
try (Scanner sc = new Scanner(System.in)) { | ||
System.out.print("Введите ФИО: "); | ||
String name = sc.nextLine(); | ||
System.out.print("\nВведите ИНН: "); | ||
String inn = sc.nextLine(); | ||
if (inn == null || !inn.matches("\\d{10}")) { | ||
throw new InnException("Введён неверный ИНН: " + inn); | ||
} | ||
System.out.printf("\nЗаказ успешно создан для:\n%s\nИНН: %s", name, inn); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
students/23K0563/23K0563-p19/src/main/java/mirea/lab19/p2/EmptyStringException.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,7 @@ | ||
package mirea.lab19.p2; | ||
|
||
public class EmptyStringException extends RuntimeException { | ||
public EmptyStringException(String message) { | ||
super(message); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
students/23K0563/23K0563-p19/src/main/java/mirea/lab19/p2/LabClass.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,40 @@ | ||
package mirea.lab19.p2; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class LabClass { | ||
private List<Student> students; | ||
|
||
LabClass() { | ||
this.students = new ArrayList<>(); | ||
} | ||
|
||
public void stadd(String name, int gpa) { | ||
students.add(new Student(name, gpa)); | ||
} | ||
|
||
public String stfind(String name) { | ||
if (name.trim().isEmpty()) { | ||
throw new EmptyStringException("Строка ФИО пустая!"); | ||
} | ||
for (Student i : students) { | ||
if (i.getName().equalsIgnoreCase(name)) { | ||
return i.toString(); | ||
} | ||
} | ||
throw new StudentNotFoundException("Студент " + name + " не найден."); | ||
} | ||
|
||
public void stlist() { | ||
System.out.println("Текущий список студентов:"); | ||
for (Student i : students) { | ||
System.out.println(i.toString()); | ||
} | ||
} | ||
|
||
public List<Student> stsortgpa() { | ||
students.sort(new StdComparator()); | ||
return students; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
students/23K0563/23K0563-p19/src/main/java/mirea/lab19/p2/LabClassDriver.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,9 @@ | ||
package mirea.lab19.p2; | ||
|
||
public abstract class LabClassDriver { | ||
public static void main(String[] args) { | ||
LabClassUI l = new LabClassUI(); | ||
l.menu(); | ||
|
||
} | ||
} |
Oops, something went wrong.