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.

Архитектурно всё правильно (почти), но код сыроват

}

[TestCase]
public void TestSubstraction()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
public void TestSubstraction()
public void TestSubtraction()

}

[TestCase]
public void TestMultiplacation()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
public void TestMultiplacation()
public void TestMultiplication()

Assert.AreEqual(1, tree.Calculate());
}

[TestCase]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Что-то с отступом не то


namespace hw4ParseTree
{
public class Addition : Operator

This comment was marked as resolved.


public Addition(char sign, INode leftChild, INode rightChild)
{
Sign = sign;
Copy link
Collaborator

Choose a reason for hiding this comment

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

А разве Addition не знает, какой у него sign? :)

Console.Write(Sign);
RightChild.Print();
Console.Write(")");
}
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

Choose a reason for hiding this comment

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

Напоминаю

private INode root;

/// <summary>
/// Функция потсроения дерева разбора
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// Функция потсроения дерева разбора
/// Функция построения дерева разбора

}
else if (line[index] == ')')
{
countBrackets--;

This comment was marked as resolved.

throw new InvalidExpressionException();
}
}
return root;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ой, а тут с отступом совсем беда

{
var tree = new ParseTree();
Console.WriteLine("Введите выражение -");
var expression = Console.ReadLine();
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.

Тут уже однозначно стало лучше, но недостаточно лучше для того, чтобы можно было поставить полные баллы

{
var str = "( / 3 2 )";
tree.BuildTree(str);
Assert.AreEqual(1.5, tree.Calculate());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ой, вещественные числа нельзя сравнивать через AreEqual с двумя аргументами. См. https://docs.nunit.org/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreEqual.html

namespace Hw4ParseTree
{
/// <summary>
/// класс для сложения
Copy link
Collaborator

Choose a reason for hiding this comment

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

Я бы написал, что это узел синтаксического дерева, который представляет оператор сложения, но так тоже ок :)

/// </summary>
public class Addition : Operator
{
public override char Sign { get; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
public override char Sign { get; }
public override char Sign => '+';

И тогда в конструкторе не надо его инициализировать

namespace Hw4ParseTree
{
/// <summary>
/// исключение для неправильных выражений6
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// исключение для неправильных выражений6
/// исключение для неправильных выражений.


namespace Hw4ParseTree
{
class Operand : INode
Copy link
Collaborator

Choose a reason for hiding this comment

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

А тут и ниже комментариев всё равно нет

{
class Operand : INode
{
public double Number { get; set; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

И я не думаю, что ему нужен сеттер (только не делайте его public-полем, пожалуйста)

Comment on lines 11 to 19
public Operand(double number)
{
Number = number;
}

public void Print()
{
Console.Write($" {Number} ");
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Это тоже можно через =>

Console.Write(Sign);
RightChild.Print();
Console.Write(")");
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Напоминаю

'-' => new Subtraction(Build(line, ref index), Build(line, ref index)),
'/' => new Division(Build(line, ref index), Build(line, ref index)),
'*' => new Multiplication(Build(line, ref index), Build(line, ref index)),
_ => throw new Exception(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Есть же специальное исключение для неправильных выражений

MikePuzanov added 2 commits June 4, 2021 02:35
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.

Окей, зачтена

/// </summary>
class Operand : INode
{
private double Number;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Поля, как известно, именуются со строчной. Если Вам сложно запомнить такие мелочи, используйте StyleCop.

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.

3 participants