Giter Site home page Giter Site logo

bcit's Introduction

BCIT

Лабораторные работы

Лабораторная работа №1

Готова без отчета

Лабораторная работа №2

Готова без отчета

Лабораторная работа №3

Не готова

bcit's People

Contributors

rbizondota avatar snipghost avatar

Watchers

James Cloos avatar

bcit's Issues

Дублирование кода

Та же проблема, что я описал тут: https://github.com/GreenRingo/BCIT/issues/1

BCIT/Lab_2/Lab_2/Program.cs

Lines 195 to 208 in 3870cb5

Console.Write("Enter height: ");
f = double.TryParse(Console.ReadLine(), out k);
if (!f)
{
Console.WriteLine("ERROR!!!!!");
continue;
}
Console.Write("Enter width: ");
f = double.TryParse(Console.ReadLine(), out l);
if (!f)
{
Console.WriteLine("ERROR!!!!!");
continue;
}

Советую вынести отдельно

Читаемость--

Именование переменных, форматирование кода, и т.д.

BCIT/Lab_2/Lab_2/Program.cs

Lines 150 to 174 in 3870cb5

bool t = true;
bool p = true;
while (p)
{
Console.Clear();
if(t) Console.WriteLine("Lab_2 by Baybarin R.\n");
t = false;
Console.Write("============\n" +
"Menu\n" +
"============\n" +
"1) Circle\n" +
"2) Rectangle\n" +
"3) Square\n" +
"0) Exit\n" +
"============\n" +
"Your choice: ");
int caseSwitch;
double k, l;
bool f;
f = int.TryParse(Console.ReadLine(), out caseSwitch);
if (!f||caseSwitch<0||caseSwitch>3)
{
Console.WriteLine("ERROR!!!!!");
continue;
}

Without try-catch

See methods of Dictionary here.

Method 1 (strange):

// If you need old_value (old_value declared earlier)
if (this._matr.TryGetValue(key, out old_value))
{
  this._matr[key] = value;
 // Maybe you will need smth like that:
 // this._matr[key] = value + old_value;
}
else
{
 this._matr.Add(key, value);
}

Method 2 (normal):

if (this._matr.ContainsKey(key))
{
 this._matr[key] = value;
}
else
{
 this._matr.Add(key, value);
}

string key = DictKey(x, y, z);
try
{
this._matr.Add(key, value);
}
catch (ArgumentException)
{
_matr[key] = value;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.