Skip to content

Commit 1fc54cb

Browse files
authored
Merge branch 'BasePractice:main' into features/lab4
2 parents f5f7499 + b522165 commit 1fc54cb

File tree

164 files changed

+3915
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+3915
-3
lines changed

pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,18 @@
3636
<module>students/23K0368</module>
3737
<module>students/23K0754</module>
3838
<module>students/24K0458</module>
39+
<module>students/23K0565</module>
3940
<module>students/23K0350</module>
4041
<module>students/23K1302</module>
4142
<module>students/23K0346</module>
4243
<module>students/24K0459</module>
4344
<module>students/23K0364</module>
4445
<module>students/23K0155</module>
4546
<module>students/23K0114</module>
46-
47+
<module>students/23K0112</module>
48+
<module>students/23K0351</module>
49+
<module>students/23K0563</module>
50+
<module>students/23K0116</module>
4751
</modules>
4852

4953
<dependencies>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<artifactId>23K0112</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0112-p01</artifactId>
12+
<description>Массивы</description>
13+
</project>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package ru.mirea.practice.s23k0112;
2+
3+
import java.util.Arrays;
4+
import java.util.Scanner;
5+
6+
public final class First {
7+
public static int factorial(int num) {
8+
int product = 1;
9+
for (int i = 1; i <= num; i++) {
10+
product *= i;
11+
}
12+
return product;
13+
}
14+
15+
public static void main(String[] args) {
16+
try (Scanner scanner = new Scanner(System.in)) {
17+
int length = 4;
18+
int sum = 0;
19+
20+
int[] array = new int[length];
21+
for (int i = 0; i < length; i++) {
22+
System.out.printf("Введите %d элемент массива: ", i);
23+
int number = scanner.nextInt();
24+
sum += number;
25+
array[i] = number;
26+
}
27+
float average = (float) sum / array.length;
28+
29+
System.out.println(Arrays.toString(array));
30+
System.out.printf("Cумма: %d%n", sum);
31+
System.out.println("Среднее: " + average);
32+
33+
System.out.println("\nЗадание 4");
34+
int[] array2 = new int[length];
35+
int min = Integer.MAX_VALUE;
36+
int max = Integer.MIN_VALUE;
37+
38+
for (int i = 0; i < length; i++) {
39+
System.out.printf("Введите %d элемент массива: ", i);
40+
array2[i] = scanner.nextInt();
41+
if (array2[i] > max) {
42+
max = array2[i];
43+
}
44+
if (array2[i] < min) {
45+
min = array2[i];
46+
}
47+
}
48+
System.out.println(Arrays.toString(array2));
49+
System.out.printf("Максимальный: %d; Минимальный: %d%n", max, min);
50+
51+
System.out.println("\nЗадание 5");
52+
if (args.length == 0) {
53+
System.out.println("No command-line arguments provided.");
54+
} else {
55+
System.out.println("Command-line arguments:");
56+
for (int j = 0; j < args.length; j++) {
57+
System.out.printf("Argument %d: %s%n", j + 1, args[j]);
58+
}
59+
}
60+
61+
System.out.println("\nЗадание 6");
62+
for (int j = 1; j <= 10; j++) {
63+
float k = (float) 1 / j;
64+
System.out.printf("%.2f%n", k);
65+
}
66+
67+
System.out.println("\nЗадание 7");
68+
System.out.print("Введите число: ");
69+
int num = scanner.nextInt();
70+
System.out.printf("factorial(%d) = %d%n", num, factorial(num));
71+
}
72+
}
73+
74+
private First() {
75+
}
76+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<artifactId>23K0112</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0112-p02</artifactId>
12+
<description>Классы</description>
13+
</project>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package ru.mirea.practice.s23k0112;
2+
3+
public class Author {
4+
private String name;
5+
private String email;
6+
private char gender;
7+
8+
public Author(String name, String email, char gender) {
9+
this.name = name;
10+
this.email = email;
11+
this.gender = gender;
12+
}
13+
14+
public String getName() {
15+
return name;
16+
}
17+
18+
public String getEmail() {
19+
return email;
20+
}
21+
22+
public char getGender() {
23+
return gender;
24+
}
25+
26+
public void setEmail(String email) {
27+
this.email = email;
28+
}
29+
30+
@Override
31+
public String toString() {
32+
return String.format("Author{Name: %s, Email: %s, Gender: %c}", name, email, gender);
33+
}
34+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package ru.mirea.practice.s23k0112;
2+
3+
public class Ball {
4+
private double x;
5+
private double y;
6+
7+
public Ball(double x, double y) {
8+
this.x = x;
9+
this.y = y;
10+
}
11+
12+
public double getX() {
13+
return x;
14+
}
15+
16+
public void setX(double x) {
17+
this.x = x;
18+
}
19+
20+
public double getY() {
21+
return y;
22+
}
23+
24+
public void setY(double y) {
25+
this.y = y;
26+
}
27+
28+
public void setXY(double x, double y) {
29+
this.x = x;
30+
this.y = y;
31+
}
32+
33+
public void move(double xdisp, double ydisp) {
34+
this.x += xdisp;
35+
this.y += ydisp;
36+
}
37+
38+
@Override
39+
public String toString() {
40+
return String.format("Ball position: (%.2f, %.2f)", x, y);
41+
}
42+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package ru.mirea.practice.s23k0112;
2+
3+
public class Dog {
4+
private String name;
5+
private int age;
6+
7+
public Dog(String name, int age) {
8+
this.name = name;
9+
this.age = age;
10+
}
11+
12+
public String getName() {
13+
return name; // Changed method name for consistency
14+
}
15+
16+
public int getAge() {
17+
return age; // Changed method name for consistency
18+
}
19+
20+
public void setAge(int newAge) { // Changed parameter name for clarity
21+
this.age = newAge;
22+
}
23+
24+
public int convertToHumanAge() {
25+
return age * 7;
26+
}
27+
28+
@Override
29+
public String toString() {
30+
return String.format("Dog's card:%nName: %s%nAge: %d%nAge in human: %d",
31+
name, age, convertToHumanAge());
32+
}
33+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package ru.mirea.practice.s23k0112;
2+
3+
import java.util.Scanner;
4+
5+
public final class TestAuthor {
6+
private TestAuthor() {
7+
8+
}
9+
10+
public static void main(String[] args) {
11+
Author author = new Author("John", "[email protected]", 'M');
12+
System.out.println("Имя автора: " + author.getName());
13+
System.out.println("Почта автора: " + author.getEmail());
14+
System.out.println("Пол автора: " + author.getGender());
15+
16+
try (Scanner scanner = new Scanner(System.in)) {
17+
System.out.println("\nВведите новую почту:");
18+
String email = scanner.next();
19+
author.setEmail(email);
20+
System.out.println(author);
21+
}
22+
}
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package ru.mirea.practice.s23k0112;
2+
3+
public final class TestBall {
4+
private TestBall() {
5+
6+
}
7+
8+
public static void main(String[] args) {
9+
Ball ball = new Ball(0, 0);
10+
System.out.println(ball.toString());
11+
12+
ball.setX(2.3);
13+
ball.setY(6.8);
14+
System.out.println(ball.toString());
15+
16+
ball.setXY(4.3, 2.9);
17+
System.out.println(ball.toString());
18+
19+
ball.move(2, 3);
20+
System.out.println(ball.toString());
21+
}
22+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package ru.mirea.practice.s23k0112;
2+
3+
public final class TestDog {
4+
private TestDog() {
5+
6+
}
7+
8+
public static void main(String[] args) {
9+
Dog[] dogs = {new Dog("Ben", 7), new Dog("John", 2), new Dog("Casper", 4)};
10+
11+
for (Dog dog : dogs) { // Enhanced for-loop for readability
12+
System.out.println(dog + "\n"); // Implicitly calls toString()
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)