-
Notifications
You must be signed in to change notification settings - Fork 69
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
1 parent
1cdff3d
commit 3da11c9
Showing
48 changed files
with
1,436 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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
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>23K0140</artifactId> | ||
<groupId>ru.mirea.practice</groupId> | ||
<version>2024.1</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>23K0140-p11</artifactId> | ||
<description>Лабораторная 11</description> | ||
</project> |
20 changes: 20 additions & 0 deletions
20
students/23K0140/23K0140-p11/src/main/java/ru/mirea/practice/s23k0140/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,20 @@ | ||
package ru.mirea.practice.s23k0140.task1; | ||
|
||
import java.util.Date; | ||
|
||
public final class Main { | ||
|
||
private Main() { | ||
|
||
} | ||
|
||
public static void main(String[] args) { | ||
String developerLastName = "Иванов"; | ||
String assignmentReceivedDate = "2024-09-28 10:00:00"; | ||
Date currentDate = new Date(); | ||
System.out.println("Фамилия разработчика: " + developerLastName); | ||
System.out.println("Дата и время получения задания: " + assignmentReceivedDate); | ||
System.out.println("Дата и время сдачи задания: " + currentDate); | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
students/23K0140/23K0140-p11/src/main/java/ru/mirea/practice/s23k0140/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,47 @@ | ||
package ru.mirea.practice.s23k0140.task2; | ||
|
||
import java.text.ParseException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.Scanner; | ||
|
||
public final class Main { | ||
|
||
private Main() { | ||
|
||
} | ||
|
||
public static void main(String[] args) { | ||
|
||
try (Scanner scanner = new Scanner(System.in)) { | ||
|
||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); | ||
dateFormat.setLenient(false); | ||
|
||
System.out.println("Введите дату и время в формате dd.MM.yyyy HH:mm:ss:"); | ||
String userInput = scanner.nextLine(); | ||
|
||
try { | ||
Date userDate = dateFormat.parse(userInput); | ||
|
||
Date currentDate = new Date(); | ||
|
||
System.out.println("Введённая дата и время: " + dateFormat.format(userDate)); | ||
System.out.println("Текущая дата и время: " + dateFormat.format(currentDate)); | ||
|
||
if (userDate.before(currentDate)) { | ||
System.out.println("Введённая дата и время раньше текущей системной даты."); | ||
} else if (userDate.after(currentDate)) { | ||
System.out.println("Введённая дата и время позже текущей системной даты."); | ||
} else { | ||
System.out.println("Введённая дата и время совпадают с текущей системной датой."); | ||
} | ||
|
||
} catch (ParseException e) { | ||
System.out.println("Ошибка: Неверный формат даты. Пожалуйста, следуйте формату dd.MM.yyyy HH:mm:ss."); | ||
} finally { | ||
scanner.close(); | ||
} | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
students/23K0140/23K0140-p11/src/main/java/ru/mirea/practice/s23k0140/task4/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,77 @@ | ||
package ru.mirea.practice.s23k0140.task4; | ||
|
||
import java.util.Calendar; | ||
import java.util.Date; | ||
import java.util.Scanner; | ||
|
||
public final class Main { | ||
|
||
private Main() { | ||
|
||
} | ||
|
||
public static void main(String[] args) { | ||
|
||
try (Scanner scanner = new Scanner(System.in)) { | ||
System.out.print("Введите год: "); | ||
final int year = scanner.nextInt(); | ||
|
||
System.out.print("Введите месяц: "); | ||
final int month = scanner.nextInt(); | ||
if (month < 1 || month > 12) { | ||
System.out.println("Ошибка: Месяц должен быть в диапазоне от 1 до 12."); | ||
return; | ||
} | ||
|
||
System.out.print("Введите день: "); | ||
final int day = scanner.nextInt(); | ||
if (day < 1 || day > 31) { | ||
System.out.println("Ошибка: День должен быть в диапазоне от 1 до 31."); | ||
return; | ||
} | ||
|
||
System.out.print("Введите часы: "); | ||
final int hour = scanner.nextInt(); | ||
if (hour < 0 || hour > 23) { | ||
System.out.println("Ошибка: Часы должны быть в диапазоне от 0 до 23."); | ||
return; | ||
} | ||
|
||
System.out.print("Введите минуты: "); | ||
final int minute = scanner.nextInt(); | ||
if (minute < 0 || minute > 59) { | ||
System.out.println("Ошибка: Минуты должны быть в диапазоне от 0 до 59."); | ||
return; | ||
} | ||
|
||
Calendar calendar = Calendar.getInstance(); | ||
calendar.set(Calendar.YEAR, year); | ||
calendar.set(Calendar.MONTH, month - 1); | ||
calendar.set(Calendar.DAY_OF_MONTH, day); | ||
calendar.set(Calendar.HOUR_OF_DAY, hour); | ||
calendar.set(Calendar.MINUTE, minute); | ||
calendar.set(Calendar.SECOND, 0); | ||
calendar.set(Calendar.MILLISECOND, 0); | ||
|
||
Date date = calendar.getTime(); | ||
|
||
System.out.println("\nСозданный объект Calendar:"); | ||
System.out.println(calendar.getTime()); | ||
|
||
System.out.println("Созданный объект Date:"); | ||
System.out.println(date); | ||
|
||
Date currentDate = new Date(); | ||
if (date.before(currentDate)) { | ||
System.out.println("Введённая дата и время ранее текущей системной даты."); | ||
} else if (date.after(currentDate)) { | ||
System.out.println("Введённая дата и время позже текущей системной даты."); | ||
} else { | ||
System.out.println("Введённая дата и время совпадают с текущей системной датой."); | ||
} | ||
|
||
} catch (Exception e) { | ||
System.out.println("Ошибка ввода. Пожалуйста, вводите только числовые значения."); | ||
} | ||
} | ||
} |
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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
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>23K0140</artifactId> | ||
<groupId>ru.mirea.practice</groupId> | ||
<version>2024.1</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>23K0140-p12</artifactId> | ||
<description>Лабораторная 12</description> | ||
</project> |
13 changes: 13 additions & 0 deletions
13
students/23K0140/23K0140-p12/src/main/java/ru/mirea/practice/s23k0140/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,13 @@ | ||
package ru.mirea.practice.s23k0140.task1; | ||
|
||
public class Circle extends Shape { | ||
|
||
public Circle(double x, double y, String color) { | ||
super(x, y, color); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Square{" + super.toString() + "}"; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
students/23K0140/23K0140-p12/src/main/java/ru/mirea/practice/s23k0140/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,14 @@ | ||
package ru.mirea.practice.s23k0140.task1; | ||
|
||
public final class Main { | ||
|
||
private Main() { | ||
} | ||
|
||
public static void main(String[] args) { | ||
Square square = new Square(2.0, 1.0, "green"); | ||
Square circle = new Square(2.0, 1.0, "yellow"); | ||
System.out.println(square); | ||
System.out.println(circle); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
students/23K0140/23K0140-p12/src/main/java/ru/mirea/practice/s23k0140/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,35 @@ | ||
package ru.mirea.practice.s23k0140.task1; | ||
|
||
public abstract class Shape { | ||
|
||
private double x; | ||
private double y; | ||
private String color; | ||
|
||
public Shape(double x, double y, String color) { | ||
this.x = x; | ||
this.y = y; | ||
this.color = color; | ||
} | ||
|
||
public double getX() { | ||
return x; | ||
} | ||
|
||
public double getY() { | ||
return y; | ||
} | ||
|
||
public String getColor() { | ||
return color; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Shape{" | ||
+ "x='" + x + '\'' | ||
+ ", y='" + y + '\'' | ||
+ ", color='" + color + '\'' | ||
+ '}'; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
students/23K0140/23K0140-p12/src/main/java/ru/mirea/practice/s23k0140/task1/Square.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,13 @@ | ||
package ru.mirea.practice.s23k0140.task1; | ||
|
||
public class Square extends Shape { | ||
|
||
public Square(double x, double y, String color) { | ||
super(x, y, color); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Square{" + super.toString() + "}"; | ||
} | ||
} |
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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
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>23K0140</artifactId> | ||
<groupId>ru.mirea.practice</groupId> | ||
<version>2024.1</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>23K0140-p13</artifactId> | ||
<description>Лабораторная 13</description> | ||
</project> |
27 changes: 27 additions & 0 deletions
27
students/23K0140/23K0140-p13/src/main/java/ru/mirea/practice/s23k0140/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,27 @@ | ||
package ru.mirea.practice.s23k0140.task1; | ||
|
||
import java.util.Locale; | ||
|
||
public abstract class Main { | ||
public static Locale ru_Ru = new Locale("ru", "Ru"); | ||
|
||
public static void stringMethod(String s) { | ||
System.out.println(s.charAt(s.length() - 1)); | ||
System.out.println(s.endsWith("!!!")); | ||
System.out.println(s.startsWith("I like")); | ||
System.out.println(s.contains("Java")); | ||
System.out.println(s.lastIndexOf("Java")); | ||
String s1 = s.replace("a", "o"); | ||
System.out.println(s1); | ||
String s2 = s1.toUpperCase(ru_Ru); | ||
System.out.println(s2); | ||
String s3 = s2.toLowerCase(ru_Ru); | ||
System.out.println(s3); | ||
String s4 = s.substring(s.lastIndexOf("Java"), s.indexOf("!")); | ||
System.out.println(s4); | ||
} | ||
|
||
public static void main(String[] args) { | ||
stringMethod("I like Java!!!"); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
students/23K0140/23K0140-p13/src/main/java/ru/mirea/practice/s23k0140/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,19 @@ | ||
package ru.mirea.practice.s23k0140.task2; | ||
|
||
public final class Main { | ||
private Main() { | ||
|
||
} | ||
|
||
public static void main(String[] args) { | ||
Person person1 = new Person("Иванов", "Иван", "Иванович"); | ||
Person person2 = new Person("Петров", "Петр", null); | ||
Person person3 = new Person("Сидоров", null, "Сидорович"); | ||
Person person4 = new Person("Кузнецов", null, null); | ||
|
||
System.out.println(person1.getFullName()); | ||
System.out.println(person2.getFullName()); | ||
System.out.println(person3.getFullName()); | ||
System.out.println(person4.getFullName()); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
students/23K0140/23K0140-p13/src/main/java/ru/mirea/practice/s23k0140/task2/Person.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,52 @@ | ||
package ru.mirea.practice.s23k0140.task2; | ||
|
||
public class Person { | ||
private String lastName; | ||
private String firstName; | ||
private String middleName; | ||
|
||
|
||
public Person(String lastName, String firstName, String middleName) { | ||
this.lastName = lastName; | ||
this.firstName = firstName; | ||
this.middleName = middleName; | ||
} | ||
|
||
|
||
public String getFullName() { | ||
StringBuilder fullName = new StringBuilder(lastName); | ||
if (firstName != null && !firstName.isEmpty()) { | ||
fullName.append(" ").append(firstName.charAt(0)).append("."); | ||
} | ||
if (middleName != null && !middleName.isEmpty()) { | ||
fullName.append(" ").append(middleName.charAt(0)).append("."); | ||
} | ||
|
||
return fullName.toString(); | ||
} | ||
|
||
public String getLastName() { | ||
return lastName; | ||
} | ||
|
||
public void setLastName(String lastName) { | ||
this.lastName = lastName; | ||
} | ||
|
||
public String getFirstName() { | ||
return firstName; | ||
} | ||
|
||
public void setFirstName(String firstName) { | ||
this.firstName = firstName; | ||
} | ||
|
||
public String getMiddleName() { | ||
return middleName; | ||
} | ||
|
||
public void setMiddleName(String middleName) { | ||
this.middleName = middleName; | ||
} | ||
|
||
} |
Oops, something went wrong.