Skip to content

Postfix calculator#3

Open
Palezehvat wants to merge 11 commits intomasterfrom
PostfixCalculator
Open

Postfix calculator#3
Palezehvat wants to merge 11 commits intomasterfrom
PostfixCalculator

Conversation

@Palezehvat
Copy link
Owner

Постфиксный калькулятор

@@ -1,208 +0,0 @@
namespace Sort;

Choose a reason for hiding this comment

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

Этот коммит удалит домашку с BWT. Если это и был план, то это всё равно незачем делать в этом пуллреквесте, удалите отдельно.

Choose a reason for hiding this comment

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

Напоминаю. Может, Вам за неё стыдно, но не всё так плохо ведь :)

@@ -0,0 +1,259 @@
namespace Sort;

Choose a reason for hiding this comment

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

Корневое пространство имён проекта по традиции называется так же, как сам проект, а раз так, то и сам проект (и решение) называется в PascalCase.


using System;

interface OperationsWithElementsStruct

Choose a reason for hiding this comment

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

В C# есть правило "одна сущность — один файл", так что этот интерфейс с очень странным называнием надо вынести в отдельный файл, переименовать и написать к нему комментарий.


interface OperationsWithElementsStruct
{
// Add element to struct

Choose a reason for hiding this comment

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

struct — это другое, Вы не понимаете :) В условии речь шла про стек

bool IsEmpty();
}

public class StackWithArray : OperationsWithElementsStruct

Choose a reason for hiding this comment

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

И к самому классу нужен комментарий

Comment on lines 155 to 168
int multiplier = 10;
int number = 0;
while (i < stringWithExpression.Length && stringWithExpression[i] >= '0' && stringWithExpression[i] <= '9')
{
number += stringWithExpression[i] - '0';
number *= multiplier;
++i;
}
number /= 10;
--i;
if (isNeedMinus)
{
number *= -1;
}

Choose a reason for hiding this comment

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

Погуглите string.Split() и int.TryParse :)

{
double numberAfter = 0;
(var isCorrect, var firstNumber) = stackExpression.RemoveElement();
(isCorrect, var secondNumber) = stackExpression.RemoveElement();

Choose a reason for hiding this comment

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

Так первый isCorrect перетрётся

{
return (false, 0);
}
return true == stackExpression.IsEmpty() ? (true, result) : (false, 0);

Choose a reason for hiding this comment

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

true == , кажется, бессмысленно


class Program
{
public static void Main(string[] args)

Choose a reason for hiding this comment

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

Используйте top-level statements

Choose a reason for hiding this comment

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

Не поправлено

// Receives the input string in which the expression is written in postfix form, finds the result
public (bool, double) ConvertToAResponse(string stringWithExpression)
{
StackList stackExpression = new StackList();

Choose a reason for hiding this comment

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

Стековый калькулятор должен знать только про интерфейс стека (то есть вообще в коде класса «Стековый калькулятор» не должно быть ни одного упоминания конкретных реализаций стека, даже если очень хочется).

Это невыполнение требований условия.

palorel and others added 4 commits March 10, 2023 22:20
…ь они идут отдельно с маленькой, при этом в каталоге отображаются с большой, а при добавлении с большой git status их не выделяет, поэтому этот комит их отдельное добавление
Другая ветка
@@ -1,208 +0,0 @@
namespace Sort;

Choose a reason for hiding this comment

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

Напоминаю. Может, Вам за неё стыдно, но не всё так плохо ведь :)

@@ -0,0 +1,16 @@
namespace StackCalculator;

interface IOperationsWithStack

Choose a reason for hiding this comment

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

Лишний пробел перед interface и фигурной скобкой ниже

Choose a reason for hiding this comment

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

И нужен комментарий к самому интерфейсу


class Program
{
public static void Main(string[] args)

Choose a reason for hiding this comment

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

Не поправлено

Comment on lines 3 to 4
using System;
class Program

Choose a reason for hiding this comment

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

Надо пустую строку

{
public static void Main(string[] args)
{
Test test = new Test();

Choose a reason for hiding this comment

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

Не пишите тип дважды


public class StackCalculator
{
private double delta = 0.0000000000001;

Choose a reason for hiding this comment

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

Suggested change
private double delta = 0.0000000000001;
private const double delta = 0.0000000000001;

// Receives the input string in which the expression is written in postfix form, finds the result
public (bool, double) ConvertToAResponse(string stringWithExpression)
{
Stack stackExpression = new();

Choose a reason for hiding this comment

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

Stack — это конкретный класс, так что требования условия всё ещё не выполняются. Хорошая попытка, но должно быть наоборот, ArrayStack наследует от интерфейса Stack

string[] expressionArray = stringWithExpression.Split(' ');
while (i < expressionArray.Length)
{
var isCorrectNumber = Int32.TryParse(expressionArray[i], out var number);

Choose a reason for hiding this comment

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

Suggested change
var isCorrectNumber = Int32.TryParse(expressionArray[i], out var number);
var isCorrectNumber = Int32.TryParse(expressionArray[i], out var number);

Comment on lines 55 to 56
public double valueStack { get; set; }
public StackElement next { get; set; }

Choose a reason for hiding this comment

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

Всё, что public, в C# пишется с заглавной

// Tests the program
public bool TestForProgram()
{
StackCalculator calculator = new StackCalculator();

Choose a reason for hiding this comment

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

Suggested change
StackCalculator calculator = new StackCalculator();
var calculator = new StackCalculator();

Copy link

@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.

Не-а, это всё равно удалит BWT, попробуйте ещё раз

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

Comments