-
Notifications
You must be signed in to change notification settings - Fork 222
Проектная работа №1. PR #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Проверочный комментарий |
| @@ -1,8 +1,12 @@ | |||
| public class Main { | |||
| public abstract class Main { | |||
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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){ |
There was a problem hiding this comment.
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
No description provided.