Apologies if this has been asked before but I'm new to programming.
Question: Whenever I create properties, I get a message stating I should convert it to an auto-property.
My program runs so should I be worried about this?
using System;
namespace ConsoleApplication12
{
struct Calculator
{
// Properties for returning addition numbers
private static long _add1, _add2;
private static long _addtotal;
public static long AddNumberOne
{
get { return _add1; } set { _add1 = value; }
}
public static long AddNumberTwo
{
get { return _add2; } set { _add2 = value; }
}
// Properties for returning multiplication numbers
private static long _mul1, _mul2;
private static long _multiplytotal;
public static long MulNumberOne
{
get { return _mul1; } set { _mul1 = value; }
}
public static long MulNumberTwo
{
get { return _mul2; } set { _mul2 = value; }
}
// Properties for returning division numbers
private static double _div1, _div2;
private static double _dividetotal;
public static double DivNumberOne
{
get { return _div1; } set { _div1 = value; }
}
public static double DivNumberTwo
{
get { return _div2; } set { _div2 = value; }
}
// Properties for returning minus numbers
private static double _min1, _min2;
private static double _minustotal;
public static double MinNumberOne
{
get { return _min1; } set { _min1 = value; }
}
public static double MinNumberTwo
{
get { return _min2; } set { _min2 = value; }
}
// Property for returning program run state
private static bool _run = true;
public static bool RunProgram
{
get { return _run; } set { _run = value; }
}
// Properties for returning total after calculation is made
public static long TotalAddition
{
get { return _addtotal; } set { _addtotal = value; }
}
public static long TotalMultiply
{
get { return _multiplytotal; } set { _multiplytotal = value; }
}
public static double TotalDivide
{
get { return _dividetotal; } set { _dividetotal = value; }
}
public static double TotalMinus
{
get { return _minustotal; } set { _minustotal = value; }
}
// Methods for calculating total
public static long AddCalculation(long a, long b)
{
TotalAddition = a + b;
return TotalAddition;
}
public static long MultiplyCalculation(long a, long b)
{
TotalMultiply = a*b;
return TotalMultiply;
}
public static double DivideCalculation(double a, double b)
{
TotalDivide = a/b;
return TotalDivide;
}
public static double MinusCalculation(double a, double b)
{
TotalMinus = a - b;
return TotalMinus;
}
// Properties for user input
private static string _input;
private static long _inputConv;
public static string InputOption
{
get { return _input; }
set { _input = value; }
}
public static long InputConversion
{
get { return _inputConv; }
set { _inputConv = value; }
}
public static void DisplayInstructionMenuAndSelectCalculatioType()
{
Console.WriteLine("What operation would you like to carry out?\n");
Console.WriteLine("1. Addition\n" +
"2. Multiplication\n" +
"3. Subtraction\n" +
"4. Division");
InputOption = Console.ReadLine();
InputConversion = Convert.ToInt64(InputOption);
}
public static void UserInputForAdditionCalculation()
{
Console.WriteLine("*******ADDITION*******");
Console.WriteLine("Enter number 1: ");
InputOption = Console.ReadLine();
AddNumberOne = Convert.ToInt64(InputOption);
Console.WriteLine("Enter number 2: ");
InputOption = Console.ReadLine();
AddNumberTwo = Convert.ToInt64(InputOption);
TotalAddition = AddCalculation(AddNumberOne, AddNumberTwo);
Console.WriteLine("\n\nResult: {0} + {1} = {2}", AddNumberOne, AddNumberTwo, TotalAddition);
Console.Write("Another calculation? YES/NO: ");
InputOption = Console.ReadLine();
}
public static void UserInputForMultiplyCalculation()
{
Console.WriteLine("*******MULTIPLY*******");
Console.WriteLine("Enter number 1: ");
InputOption = Console.ReadLine();
MulNumberOne = Convert.ToInt64(InputOption);
Console.WriteLine("Enter number 2: ");
InputOption = Console.ReadLine();
MulNumberTwo = Convert.ToInt64(InputOption);
TotalMultiply = MultiplyCalculation(MulNumberOne, MulNumberTwo);
Console.WriteLine("\n\nResult: {0} x {1} = {2}", MulNumberOne, MulNumberTwo, TotalMultiply);
Console.Write("Another calculation? YES/NO: ");
InputOption = Console.ReadLine();
}
public static void UserInputForSubtractCalculation()
{
Console.WriteLine("*******SUBTRACT*******");
Console.WriteLine("Enter number 1: ");
InputOption = Console.ReadLine();
MinNumberOne = Convert.ToInt64(InputOption);
Console.WriteLine("Enter number 2: ");
InputOption = Console.ReadLine();
MinNumberTwo = Convert.ToInt64(InputOption);
TotalMinus = MinusCalculation(MinNumberOne, MinNumberTwo);
Console.WriteLine("\n\nResult: {0} - {1} = {2}", MinNumberOne, MinNumberTwo, TotalMinus);
Console.Write("Another calculation? YES/NO: ");
InputOption = Console.ReadLine();
}
public static void UserInputForDivisionCalculation()
{
Console.WriteLine("*******DIVISION*******");
Console.Write("Enter number 1: ");
InputOption = Console.ReadLine();
DivNumberOne = Convert.ToInt64(InputOption);
Console.Write("Enter number 2: ");
InputOption = Console.ReadLine();
DivNumberTwo = Convert.ToInt64(InputOption);
TotalDivide = DivideCalculation(DivNumberOne, DivNumberTwo);
Console.WriteLine("\n\nResult: {0} / {1} = {2}", DivNumberOne, DivNumberTwo, TotalDivide);
Console.Write("Another calculation? YES/NO: ");
InputOption = Console.ReadLine();
}
public static void DisplayMenuOrExitProgram()
{
switch (InputOption)
{
case "YES":
DisplayInstructionMenuAndSelectCalculatioType();
break;
case "NO":
RunProgram = false;
break;
default:
RunProgram = false;
break;
}
}
public static void SwitchCalculationsAndDisplayResults()
{
while (RunProgram)
{
switch (InputConversion)
{
case 1:
UserInputForAdditionCalculation();
DisplayMenuOrExitProgram();
break;
case 2:
UserInputForMultiplyCalculation();
DisplayMenuOrExitProgram();
break;
case 3:
UserInputForSubtractCalculation();
DisplayMenuOrExitProgram();
break;
case 4:
UserInputForDivisionCalculation();
DisplayMenuOrExitProgram();
break;
default:
Console.WriteLine("Something went wrong, sorry");
break;
}
}
}
}
}