-
Notifications
You must be signed in to change notification settings - Fork 0
Hw7 calculator #13
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?
Hw7 calculator #13
Conversation
yurii-litvinov
left a comment
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.
Ещё Form1 --- такой себе заголовок окна. В целом всё ок, но код сыроват.
|
|
||
| namespace hw7CalculatorWinForms | ||
| { | ||
| public partial class CalculatorForms : Form |
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.
Нужны комментарии
| { | ||
| public partial class CalculatorForms : Form | ||
| { | ||
| private string NumberFirst = ""; |
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.
Поля именуются в camelCase
| public CalculatorForms() | ||
| { | ||
| InitializeComponent(); | ||
| } |
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.
Лучше через =>
| private void Form1_Load(object sender, EventArgs e) | ||
| { | ||
|
|
||
| } |
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.
Это не нужно и надо убрать
|
|
||
| private void buttonResetAll_MouseClick(object sender, MouseEventArgs e) | ||
| { | ||
| NumberFirst = NumberSecond = Operator = ""; |
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.
Вообще, по стайлгайду положено (и в сообществе принято) один оператор на одной строке, тут аж три оператора
| private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e) | ||
| { | ||
|
|
||
| } | ||
|
|
||
| private void tableLayoutPanel1_Paint_1(object sender, PaintEventArgs e) | ||
| { | ||
|
|
||
| } |
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.
Тоже что-то ненужное
| using System.Text; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace hw7CalculatorWinForms |
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.
Кстати, имя пространства имён поправьте, пожалуйста
| switch (sign) | ||
| { | ||
| case "+": | ||
| str1 = Convert.ToString(double.Parse(str1) + double.Parse(str2)); |
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.
Правда ли строки --- самый эффективный и правильный способ хранения данных для калькулятора?
yurii-litvinov
left a comment
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.
Использовать кнопку в качестве контрола для вывода --- это, скажем так, необычно, и требует обоснования.
|
|
||
| private int countNumber = 0; | ||
|
|
||
| private string Operator = ""; |
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.
А тут почему-то с заглавной оставили
| buttonText.Text = numberSecond; | ||
| } | ||
| } | ||
| isMinus = !isMinus; |
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.
Как это... ненадёжно. Очень легко забыть isMinus сбросить, и оно будет откусывать первую цифру обычного числа. Попробуйте, например, ввести 1, нажать +/-, нажать C, нажать 2 и снова +/-. А ещё так можно получить креш, подумайте как :)
| isMinus = !isMinus; | ||
| } | ||
|
|
||
| private void buttonPlus_MouseClick(object sender, MouseEventArgs e) |
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.
Неудачное название метода
| CalculatorTools.Calculate(ref number1, number2, Operator); | ||
| numberFirst = Convert.ToString(number1); | ||
| numberSecond = ""; | ||
| Operator =""; |
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.
Пробела не хватает
| number1 = number1 / number2; | ||
| break; | ||
| } | ||
| } |
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.
Негусто. Как раз сюда можно было бы вынести управление состоянием из формы с калькулятором, которая должна быть максимально простой
yurii-litvinov
left a comment
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.
Ага. Зачтена
No description provided.