Repository navigation
Conversation
| Calculator(){ | ||
| numberPeople(); | ||
| addProduct(); | ||
| totals(); |
There was a problem hiding this comment.
Не очень правильно делать основную работу класса в конструкторе, он нужен для инициализации, передачи аргументов снаружи
|
|
||
| while (true) { | ||
| System.out.println("На скольки человек необходимо разделить счет?"); | ||
| number = scanner.nextInt(); |
There was a problem hiding this comment.
hasNextInt
| System.out.println("Введите название товара"); | ||
| this.product = scanner.next(); | ||
| System.out.println("Введите цену товара"); | ||
| this.price = scanner.nextFloat(); |
There was a problem hiding this comment.
hasNextFloat
| else if (lastnumber==1) | ||
| rub = "рубль"; | ||
| else | ||
| rub = "рубля"; |
There was a problem hiding this comment.
| AddProduct nomenclature = new AddProduct(); | ||
| amount += nomenclature.price; | ||
| products = products +"\n"+ nomenclature.product; | ||
| System.out.println("Вы хотите добавить еще один товар?"); |
There was a problem hiding this comment.
С точки зрения пользователя было бы удобнее здесь уточнить, что нужно ввести в консоль, чтобы завершить добавление товаров
| public void totals(){ | ||
|
|
||
| System.out.println("Добавленные товары: \n" + products); | ||
| System.out.println("Стоимость товаров: " + amount);//String.format("%.2f",amount)); |
There was a problem hiding this comment.
Закомментированный код лучше убрать.
2. Исправил ввод цены 3. Исправил ввод количества человек 4. Исправил окончание слова рубль
|
|
||
| } else { | ||
| System.out.println("Введите положительное число"); | ||
| scanner = new Scanner(System.in); |
There was a problem hiding this comment.
Тут и выше можно не создавать каждый раз новый инстанс класса Scanner
No description provided.