Skip to content

Commit

Permalink
Лабораторная 11-20
Browse files Browse the repository at this point in the history
  • Loading branch information
dendrokton committed Nov 7, 2024
1 parent 01db124 commit 441a969
Show file tree
Hide file tree
Showing 44 changed files with 1,085 additions and 0 deletions.
13 changes: 13 additions & 0 deletions students/23K0130/23K0130-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>23K0130</artifactId>
<groupId>ru.mirea.practice</groupId>
<version>2024.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>23K0130-p11</artifactId>
<description>11 задание</description>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ru.mirea.practice.s23k0130;

public final class Main {

private Main() {

}

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

import java.util.Date;

public abstract class Developer {
public static void main(String[] args) {
String developerLastName = "Еров";
String assignmentReceivedDate = "Fri Nov 01 10:00:00 MSK 2024";
Date currentDate = new Date();
System.out.println("Фамилия разработчика: " + developerLastName);
System.out.println("Дата и время получения задания: " + assignmentReceivedDate);
System.out.println("Дата и время сдачи задания: " + currentDate);
}
}
13 changes: 13 additions & 0 deletions students/23K0130/23K0130-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>23K0130</artifactId>
<groupId>ru.mirea.practice</groupId>
<version>2024.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>23K0130-p12</artifactId>
<description>12 задание</description>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ru.mirea.practice.s23k0130;

public final class Main {

private Main() {

}

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

public final class Main {

private Main() {
}

public static void main(String[] args) {
Square square = new Square(1.0, 2.0, "red");
Square triangle = new Square(1.0, 2.0, "blue");
System.out.println(square);
System.out.println(triangle);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package ru.mirea.practice.s23k0130.task;

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.s23k0130.task;

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,13 @@
package ru.mirea.practice.s23k0130.task;

public class Triangle extends Shape {

public Triangle(double x, double y, String color) {
super(x, y, color);
}

@Override
public String toString() {
return "Triangle{" + super.toString() + "}";
}
}
13 changes: 13 additions & 0 deletions students/23K0130/23K0130-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>23K0130</artifactId>
<groupId>ru.mirea.practice</groupId>
<version>2024.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>23K0130-p13</artifactId>
<description>13 задание</description>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ru.mirea.practice.s23k0130;

public final class Main {

private Main() {

}

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

import java.util.Locale;

public final class Main {

private Main() {

}

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

}
13 changes: 13 additions & 0 deletions students/23K0130/23K0130-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>23K0130</artifactId>
<groupId>ru.mirea.practice</groupId>
<version>2024.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>23K0130-p14</artifactId>
<description>14 задание</description>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ru.mirea.practice.s23k0130;

public final class Main {

private Main() {

}

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

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

public final class Main {

private Main() {

}

public static void main(String[] args) {
String correctString = "abcdefghijklmnopqrstuv18340";
String incorrectString = "abcdefghijklmnoasdfasdpqrstuv18340";

String regex = "^abcdefghijklmnopqrstuv18340$";
Pattern pattern = Pattern.compile(regex);

Matcher matcher1 = pattern.matcher(correctString);
Matcher matcher2 = pattern.matcher(incorrectString);

System.out.println(matcher1.matches());
System.out.println(matcher2.matches());
}
}
Loading

0 comments on commit 441a969

Please sign in to comment.