Skip to content

Conversation

@MikePuzanov
Copy link
Owner

No description provided.

Copy link
Collaborator

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

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

Ещё Form1 --- такой себе заголовок окна. В целом всё ок, но код сыроват.


namespace hw7CalculatorWinForms
{
public partial class CalculatorForms : Form
Copy link
Collaborator

Choose a reason for hiding this comment

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

Нужны комментарии

{
public partial class CalculatorForms : Form
{
private string NumberFirst = "";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Поля именуются в camelCase

public CalculatorForms()
{
InitializeComponent();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Лучше через =>

private void Form1_Load(object sender, EventArgs e)
{

}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Это не нужно и надо убрать


private void buttonResetAll_MouseClick(object sender, MouseEventArgs e)
{
NumberFirst = NumberSecond = Operator = "";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Вообще, по стайлгайду положено (и в сообществе принято) один оператор на одной строке, тут аж три оператора

Comment on lines 159 to 167
private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
{

}

private void tableLayoutPanel1_Paint_1(object sender, PaintEventArgs e)
{

}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Тоже что-то ненужное

using System.Text;
using System.Threading.Tasks;

namespace hw7CalculatorWinForms
Copy link
Collaborator

Choose a reason for hiding this comment

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

Кстати, имя пространства имён поправьте, пожалуйста

switch (sign)
{
case "+":
str1 = Convert.ToString(double.Parse(str1) + double.Parse(str2));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Правда ли строки --- самый эффективный и правильный способ хранения данных для калькулятора?

Copy link
Collaborator

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

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

Использовать кнопку в качестве контрола для вывода --- это, скажем так, необычно, и требует обоснования.


private int countNumber = 0;

private string Operator = "";
Copy link
Collaborator

Choose a reason for hiding this comment

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

А тут почему-то с заглавной оставили

buttonText.Text = numberSecond;
}
}
isMinus = !isMinus;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Как это... ненадёжно. Очень легко забыть isMinus сбросить, и оно будет откусывать первую цифру обычного числа. Попробуйте, например, ввести 1, нажать +/-, нажать C, нажать 2 и снова +/-. А ещё так можно получить креш, подумайте как :)

isMinus = !isMinus;
}

private void buttonPlus_MouseClick(object sender, MouseEventArgs e)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Неудачное название метода

CalculatorTools.Calculate(ref number1, number2, Operator);
numberFirst = Convert.ToString(number1);
numberSecond = "";
Operator ="";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Пробела не хватает

number1 = number1 / number2;
break;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Негусто. Как раз сюда можно было бы вынести управление состоянием из формы с калькулятором, которая должна быть максимально простой

Copy link
Collaborator

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

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

Ага. Зачтена

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