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

Rychkov PW1#84

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

Rychkov PW1 #84
Saharok1209 wants to merge 4 commits intoYandex-Practicum:master from
Saharok1209:master

Conversation

@Saharok1209
Copy link

@Saharok1209 Saharok1209 commented Oct 24, 2022

Привет, это моя проектная работаNo1

public String calculationNameProduct(){
for (int i = 0; i < product.getNameProduct().size(); i++) {
allProducts = allProducts + " " + product.getNameProduct().get(i);
}return allProducts;
Copy link

@MagicUnderHood MagicUnderHood Oct 25, 2022

Choose a reason for hiding this comment

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

Можешь применить в студии автоформатирование (в выбранном файле, сверху вкладка Code - Reformat Code, либо Ctrl+Alt+L), тогда автоматически код выправится

System.out.println("Your price per guest: " + calculation.calculationPriceProduct() / people + " 'rubles.penni'");

}
public static int people(){
Copy link

@MagicUnderHood MagicUnderHood Oct 25, 2022

Choose a reason for hiding this comment

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

Студия подсказывает, что возвращаемый тип функции никак не используется, тогда можно его убрать, или всё-таки использовать. Методы лучше называть с глаголом, например, readPeople или getPeople (это если возвращаемый результат будет использоваться)

}
return people;
}
public static Product addProduct(){
Copy link

@MagicUnderHood MagicUnderHood Oct 25, 2022

Choose a reason for hiding this comment

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

Студия подсказывает, что возвращаемый тип функции никак не используется, тогда можно его убрать, или всё-таки использовать

@@ -0,0 +1,22 @@
import java.util.ArrayList;

public class Product {
Copy link

@MagicUnderHood MagicUnderHood Oct 25, 2022

Choose a reason for hiding this comment

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

Класс содержит информацию не о продукте, а обо всех продуктах, так что можно назвать его Menu или хотя бы Products

import java.util.ArrayList;

public class Product {
static ArrayList<String> nameProduct = new ArrayList<>();
Copy link

@MagicUnderHood MagicUnderHood Oct 25, 2022

Choose a reason for hiding this comment

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

Поскольку в этой переменной хранится не имя одного продукта, а все продукты, лучше ее назвать productNames


public class Product {
static ArrayList<String> nameProduct = new ArrayList<>();
static ArrayList<Double> priceProduct = new ArrayList<>();
Copy link

@MagicUnderHood MagicUnderHood Oct 25, 2022

Choose a reason for hiding this comment

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

Аналогично с nameProduct

Product.priceProduct.add(priceProduct);
}

public ArrayList<String> getNameProduct() {
Copy link

@MagicUnderHood MagicUnderHood Oct 25, 2022

Choose a reason for hiding this comment

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

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

}
}else{
System.out.println("invalid input");
scan.nextInt();
Copy link

@MagicUnderHood MagicUnderHood Oct 25, 2022

Choose a reason for hiding this comment

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

Здесь нужен просто scan.next();, иначе приложение упадет, поскольку мы проверили, что !scan.hasNextInt()


if(Math.round(productPrice)%10 == 1 && Math.round(productPrice)%100 != 11){
return "ruble";
}else if((Math.round(productPrice)%10) <= 4 && (Math.round(productPrice)%100 >= 2) && (Math.round(productPrice)%100)/10 != 2){
Copy link

@MagicUnderHood MagicUnderHood Oct 25, 2022

Choose a reason for hiding this comment

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

Повторяющийся код Math.round(productPrice) и Math.round(productPrice)%10, Math.round(productPrice)%100 можно вынести в переменные

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 によって変換されたページ (->オリジナル) /