Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Проектная работа No1. PR#112

Open
AugustIva wants to merge 4 commits intoYandex-Practicum:master from
AugustIva:master
Open

Проектная работа No1. PR #112
AugustIva wants to merge 4 commits intoYandex-Practicum:master from
AugustIva:master

Conversation

@AugustIva
Copy link

@AugustIva AugustIva commented Nov 1, 2022

No description provided.

Copy link
Author

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

AugustIva reacted with eyes emoji

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

@MagicUnderHood MagicUnderHood Nov 2, 2022

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);
Copy link

@MagicUnderHood MagicUnderHood Nov 2, 2022

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() {
Copy link

@MagicUnderHood MagicUnderHood Nov 2, 2022

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() {
Copy link

@MagicUnderHood MagicUnderHood Nov 2, 2022

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
Copy link

@MagicUnderHood MagicUnderHood Nov 2, 2022

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
Copy link

@MagicUnderHood MagicUnderHood Nov 2, 2022

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;
Copy link

@MagicUnderHood MagicUnderHood Nov 2, 2022

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){
Copy link

@MagicUnderHood MagicUnderHood Nov 2, 2022

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

Reviewers

1 more reviewer

@MagicUnderHood MagicUnderHood MagicUnderHood left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /