Класс не реализует член интерфейса - C#
Формулировка задачи:
Добрый вечер!
Имеется безумно сложная лабораторная в которой я не могу вызвать методы и сделать так,чтобы второй класс унаследовался от первого и реализовал интерфейс "figura".Буду всей душой благодарен ,если кто -нибудь объяснит мне и покажет как это делается.Заранее очень извиняюсь ,если своим кодом затрону чьи-то чувства .Собственно:
Листинг программы
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication2
- {
- class Program
- {
- static void Main(string[] args)
- {
- figura s = new pervcl();
- s.treygolnic();
- s.pltreyg();
- s.kvadrat();
- s.perimkvadr();
- }
- }
- interface figura
- {
- void treygolnic();
- void pltreyg();
- void kvadrat();
- void perimkvadr();
- }
- class pervcl : figura
- {
- double l;
- double x;
- double p;
- double r;
- double s;
- double y;
- double u;
- double q;
- void figura.treygolnic()
- {
- Console.WriteLine("1)Значения треугольника:\nВведите x");
- this.x = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Введите y");
- this.y = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Введите l");
- this.l = Convert.ToInt32(Console.ReadLine());
- this.p = (x + y + l) / 2;
- Console.WriteLine("Введите r");
- this.r = Convert.ToInt32(Console.ReadLine());
- this.s = p * r;
- }
- void figura.pltreyg()
- {
- Console.Write("Площадь треугольника = {0} ", s);
- Console.ReadLine();
- }
- class vtorclpervcl : pervcl, figura
- {
- void figura.kvadrat()
- {
- Console.WriteLine("\n2)Введите сторону квадратa a ");
- this.q = Convert.ToInt32(Console.ReadLine());
- this.u = q * 4;
- }
- void figura.perimkvadr()
- {
- Console.WriteLine("Периметр квадрата = {0}", u);
- Console.ReadLine();
- Console.ReadKey();
- }
- }
- }
- }
Решение задачи: «Класс не реализует член интерфейса»
textual
Листинг программы
- public class Program
- {
- private static void Main(string[] args)
- {
- figura s = new vtorclpervcl();
- s.treygolnic();
- s.pltreyg();
- s.kvadrat();
- s.perimkvadr();
- }
- interface figura
- {
- void treygolnic();
- void pltreyg();
- void kvadrat();
- void perimkvadr();
- }
- abstract class pervcl : figura
- {
- protected double l;
- protected double x;
- protected double p;
- protected double r;
- protected double s;
- protected double y;
- protected double u;
- protected double q;
- public void treygolnic()
- {
- Console.WriteLine("1)Значения треугольника:\nВведите x");
- this.x = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Введите y");
- this.y = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Введите l");
- this.l = Convert.ToInt32(Console.ReadLine());
- this.p = (x + y + l) / 2;
- Console.WriteLine("Введите r");
- this.r = Convert.ToInt32(Console.ReadLine());
- this.s = p * r;
- }
- public void pltreyg()
- {
- Console.Write("Площадь треугольника = {0} ", s);
- Console.ReadLine();
- }
- public abstract void kvadrat();
- public abstract void perimkvadr();
- }
- class vtorclpervcl : pervcl
- {
- public override void kvadrat()
- {
- Console.WriteLine("\n2)Введите сторону квадратa a ");
- this.q = Convert.ToInt32(Console.ReadLine());
- this.u = q * 4;
- }
- public override void perimkvadr()
- {
- Console.WriteLine("Периметр квадрата = {0}", u);
- Console.ReadLine();
- Console.ReadKey();
- }
- }
- }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д