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

11-32 #717

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
13 changes: 13 additions & 0 deletions students/23K0623/23K0623-p011/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: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>23K0623</artifactId>
<groupId>ru.mirea.practice</groupId>
<version>2024.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>23K0623-p011</artifactId>
<description>Массивы</description>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package ru.mirea.practice.s23k0623;

import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Scanner;

public final class DateComparison {

private DateComparison() {

}

public static void main(String[] args) {
try (Scanner scanner = new Scanner(System.in)) {
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
System.out.println("Введите дату в формате yyyy-MM-dd:");
String userInput = scanner.nextLine();

try {
LocalDate userDate = LocalDate.parse(userInput, dateFormatter);

LocalDate currentDate = LocalDate.now();

if (userDate.isBefore(currentDate)) {
System.out.println("Введенная дата раньше текущей даты.");
} else if (userDate.isAfter(currentDate)) {
System.out.println("Введенная дата позже текущей даты.");
} else {
System.out.println("Введенная дата совпадает с текущей датой.");
}

LocalTime currentTime = LocalTime.now();
System.out.println("Текущее системное время: " + currentTime);

} catch (DateTimeParseException e) {
System.out.println("Неверный формат даты. Пожалуйста, введите дату в формате yyyy-MM-dd.");
} finally {
scanner.close();
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ru.mirea.practice.s23k0623;

import java.util.Date;

public final class Developer {

private Developer() {

}

public static void main(String[] args) {
String developerLastName = "Иванов";
String assignmentReceivedDate = "2024-09-24 10:00:00";
Date currentDate = new Date();
System.out.println("Фамилия разработчика: " + developerLastName);
System.out.println("Дата и время получения задания: " + assignmentReceivedDate);
System.out.println("Дата и время сдачи задания: " + currentDate);
}


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

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() + "}";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package ru.mirea.practice.s23k0623;

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 + '\''
+ '}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package ru.mirea.practice.s23k0623;

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() + "}";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package ru.mirea.practice.s23k0623;

public final class Twotask {

private Twotask() {
}

public static void main(String[] args) {
Square square = new Square(1.0, 2.0, "red");
Square circle = new Square(1.0, 2.0, "blue");
System.out.println(square);
System.out.println(circle);
}
}
13 changes: 13 additions & 0 deletions students/23K0623/23K0623-p013/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: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>23K0623</artifactId>
<groupId>ru.mirea.practice</groupId>
<version>2024.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>23K0623-p013</artifactId>
<description>Массивы</description>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package ru.mirea.practice.s23k0623;

public class Address {
private String country;
private String region;
private String city;
private String street;
private String house;
private String building;
private String apartment;

public Address(String country, String region, String city, String street, String house, String building, String apartment) {
this.country = country;
this.region = region;
this.city = city;
this.street = street;
this.house = house;
this.building = building;
this.apartment = apartment;
}

@Override
public String toString() {
return String.join(", ", country, region, city, street, house, building, apartment);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package ru.mirea.practice.s23k0623;

import java.util.Locale;

public final class First {

private First() {

}

public static void main(String[] args) {
String input = "I like Java!!!";
printLastCharacter(input);
endsWithMarks(input);
startsWithILike(input);
containsJava(input);
findSubstringPosition(input);
System.out.println(replaceAWithO(input));
System.out.println(convertToUpperCase(input));
System.out.println(convertToLowerCase(input));
System.out.println(cutOutSubstring(input));
}

public static void printLastCharacter(String str) {
if (str != null && str.length() > 0) {
char lastChar = str.charAt(str.length() - 1);
System.out.println("Последний символ строки: " + lastChar);
} else {
System.out.println("Строка пуста или null.");
}
}

public static void endsWithMarks(String str) {
if (str.endsWith("!!!")) {
System.out.println("Строка заканчивается на \"!!!\"");
} else {
System.out.println("Строка не заканчивается на \"!!!\"");
}
}

public static void startsWithILike(String str) {
if (str.startsWith("I like")) {
System.out.println("Строка начинается с \"I like!\"");
} else {
System.out.println("Строка не начинается с \"I like!\"");
}
}

public static void containsJava(String str) {
if (str.contains("Java")) {
System.out.println("Строка содержит \"Java\"");
} else {
System.out.println("Строка не содержит \"Java\"");
}
}

public static void findSubstringPosition(String str) {
if (str.indexOf("Java") != -1) {
System.out.println("Подстрока \"Java\" найдена на позиции: " + str.indexOf("Java"));
} else {
System.out.println("Подстрока \"Java\" не найдена.");
}
}

public static String replaceAWithO(String str) {
return str.replace('a', 'o');
}

public static String convertToUpperCase(String str) {
return str.toUpperCase(Locale.US);
}

public static String convertToLowerCase(String str) {
return str.toLowerCase(Locale.US);
}

public static String cutOutSubstring(String str) {
int startIndex = str.indexOf("Java");
int endIndex = startIndex + "Java".length();
return str.substring(startIndex, endIndex);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package ru.mirea.practice.s23k0623;

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;
}

}
Loading
Loading