Skip to content

Conversation

@AugustIva
Copy link

No description provided.

@AugustIva
Copy link
Author

Проверочный комментарий

@@ -1,8 +1,12 @@
public class Main {
public abstract class Main {

Choose a reason for hiding this comment

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

Abstract у Main можно убрать. Дальше по курсу будет рассказано, что это такое, но пока не нужно

import java.util.ArrayList;

public class ProductsList {
static Scanner scanner = new Scanner(System.in);

Choose a reason for hiding this comment

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

Можно убрать все модификаторы static, а при вызове методов в main создавать экземпляр класса ProductsList , и вызывать методы у него. Дальше по курсу будет рассказано, для чего static нужен


//**********************************************************************************************
//Метод для подсчёта гостей
public static int menuChoice() {

Choose a reason for hiding this comment

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

Студия подсказывает, что возвращаемый тип метода не используется. Можно либо сделать метод void, либо использовать возвращаемый результат


//**********************************************************************************************
//Метод для добавления названия и цены товарам
public static void productsChoice() {

Choose a reason for hiding this comment

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

Метод можно сделать приватным, поскольку он используется только внутри этого класса

static Scanner scanner = new Scanner(System.in);
static String products; //Для названия товара
static double price; //Для цены
static ArrayList<String> listString = new ArrayList<>(); //Список для String

Choose a reason for hiding this comment

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

Лучше назвать списки очевиднее, productList или products и priceList или prices

static String products; //Для названия товара
static double price; //Для цены
static ArrayList<String> listString = new ArrayList<>(); //Список для String
static ArrayList<Double> listDouble = new ArrayList<>(); //Список для Double

Choose a reason for hiding this comment

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

Можно сделать ещё один класс, Product или Food, с полями name и price, и использовать его для записи каждого кушанья. Тогда вместо двух списков понадобится один список кушаний ArrayList<Food>

}
System.out.println("Всего накушали: " + endingRUB(sum));
System.out.println("Если по-чесноку, то с каждого: " + endingRUB(sum / numbersOfGuests));
return null;

Choose a reason for hiding this comment

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

Лучше сделать метод void вместо возвращаемого типа Double, и эта строчка будет не нужна

else if (ending >=2 && ending <= 4){
return formatEnding + " рубля";
}
else if (ending >= 5 && ending <= 20){

Choose a reason for hiding this comment

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

Поскольку ты проверяешь здесь результат деления по модулю 10 (%10), он не может быть больше 9, поэтому часть с ending <= 20 всегда будет true. Лучше здесь поставить default, а для проверки, что число у нас между 11 и 19, добавить перед этим if-else один с условием, что (int)sum % 100 >= 11 и <= 19

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