По дисциплине : технологии программирования
Выполнил студент группы : ИНС-б-о-20-1
ФИО полностью : Зайгов Адам Магамедович
Номер индивидуального варианта: 7
Название лабораторной работы: конструктор класса.перегрузка методов класса.
using System;
using System.IO;
namespace Зайгов7
{
class Program
static void Main(string[] args)
{
#if !DEBUG
TextReader save_in = Console.In;
var new_out = new StreamWriter(@"par_output.txt");
var new_in = new StreamReader(@"par_input.txt");
Console.SetOut(new_out);
Console.SetIn(new_in);
#endif
Par p1, p2;
#if DEBUG
p2 = new Par(5.7, 11, 18);
p2.Info(ConsoleColor.Yellow, ConsoleColor.Blue);
#endif
p1= Par.CreateParFromFile();
p1.Info();
p2= new Par (5.6, 5.11, 10.5);
p2.Info();
#endif
Console.SetIn(save_in); new_in.Close();
#endif
#if DEBUG
#endif
}
internal class Par
{
private double a, b, c;
public Par() { }
public Par(double pA, double pB, double pC)
{
a = pA; b = pB; c = pC;
{
a = Convert.ToDouble(Console.ReadLine());
c = Convert.ToDouble(Console.ReadLine());
}
public static Par CreateParFromFile()
{
double aa = Convert.ToDouble(Console.ReadLine());
double cc = Convert.ToDouble(Console.ReadLine());
return new Par(aa, bb, cc);
}
public double GetV() { return a * b * c; }
public void Info()
{
String str =
"* +\n" +
"* Параллелепипед +\n" +
"* +\n" +
"********************************+\n";
Console.WriteLine(str);
Console.Write(string.Format(
"A={0:0.00} ", a));
Console.Write(string.Format(
"B={0:0.00} ", b));
Console.WriteLine(string.Format(
"C={0:0.00} ", c));
Console.WriteLine(string.Format("V={0:0.00}", GetV()));
Console.WriteLine(string.Format("S={0:0.00}", GetS()));
}
public void Info(ConsoleColor fg, ConsoleColor bgc)
Console.ForegroundColor = fg;
Console.BackgroundColor = bgc;
Console.Clear();
Info();
}
}
}
Класс «Куб». Реализовать ввод и вывод полей данных, вычисление объема, площади поверхности, а также вывод информации об объекте.
using System;
using System.IO;
namespace Зайгов7
{
class Program
static void Main(string[] args)
{
#if !DEBUG
TextReader save_in = Console.In;
var new_out = new StreamWriter(@"par_output.txt");
var new_in = new StreamReader(@"par_input.txt");
Console.SetOut(new_out);
Console.SetIn(new_in);
#endif
Par p1, p2;
#if DEBUG
p2 = new Par(5);
p2.Info(ConsoleColor.Yellow, ConsoleColor.Blue);
#endif
p1= Par.CreateParFromFile();
p1.Info();
#endif
#if !DEBUG
Console.SetIn(save_in); new_in.Close();
#endif
#if DEBUG
#endif
}
internal class Par
{
private double a;
public Par() { }
public Par(double pA)
{
a = pA;
{
a = Convert.ToDouble(Console.ReadLine());
{
double aa = Convert.ToDouble(Console.ReadLine());
return new Par(aa);
}
public double GetV() { return a * a * 6; }
public void Info()
{
String str =
" _________\n" +
"| |\n" +
"| |\n" +
"| |\n" +
"| |\n" +
"|_________|\n" +
"****************\n";
Console.WriteLine(str);
Console.WriteLine(string.Format(
"X={0:0.00} ", a));
Console.WriteLine(string.Format("Объем={0:0.00}", GetS()));
Console.WriteLine(string.Format("Площадь поверхности={0:0.00}", GetV()));
}
public void Info(ConsoleColor fg, ConsoleColor bgc)
Console.ForegroundColor = fg;
Console.BackgroundColor = bgc;
Console.Clear();
Info();
}
}
}