Skip to content

Спринт 2 Проверочная №1 от 21.10.2023 - #1

Open
Nataliya2288 wants to merge 2 commits into
mainfrom
dev
Open

Nataliya2288 wants to merge 2 commits into
mainfrom
dev

Conversation

@Nataliya2288

Copy link
Copy Markdown
Owner

Направляю на проверку первую работу

Comment on lines +31 to +35
Product product = new Product();
double sum = 0.00f;
String menu = "";
Scanner scannerAdd = new Scanner(System.in);
int persons = Main.countOfGuests();// ссылка на число гостей из класса майн

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это тоже можно объявить в функции ниже, а не в классе

Comment on lines +49 to +61
if ((Math.floor(personPay) % 100 >= 11) && (Math.floor(personPay) % 100 <= 19)) {
String format = "Каждый гость должен: %.2f рублей";
System.out.println(String.format(format, personPay));
} else if (Math.floor(personPay) % 10 > 5) {
String format = "Каждый гость должен: %.2f рублей";
System.out.println(String.format(format, personPay));
} else if ((2 <= Math.floor(personPay) % 10) && (Math.floor(personPay) % 10 <= 4)) {
String format = "Каждый гость должен: %.2f рубля";
System.out.println(String.format(format, personPay));
} else {
String format = "Каждый гость должен: %.2f рубль";
System.out.println(String.format(format, personPay));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут код в каждой ветке повторяется, лучше повторения вынести в отдельную функцию

@@ -0,0 +1,67 @@
import java.util.Scanner;
public class Calculate {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Классы принято называть существительными

String name;
double price;

void input() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Функции принято глаголами называть, эту например можно назвать readInfo или fill

Comment thread src/main/java/Main.java
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
static int Guests;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Названия переменных принято начинать с маленьких букв

Comment thread src/main/java/Main.java
scanner.nextLine();
}
}
return Guests;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Раз эта функция возвращает число человек, то саму переменную можно сделать private и пользоваться только этой функцией, чтобы не было путаницы при выборе чем пользоваться снаружи - переменной Guests или функцией countOfGuests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants