Класс не реализует член интерфейса - C#

Узнай цену своей работы

Формулировка задачи:

Добрый вечер! Имеется безумно сложная лабораторная в которой я не могу вызвать методы и сделать так,чтобы второй класс унаследовался от первого и реализовал интерфейс "figura".Буду всей душой благодарен ,если кто -нибудь объяснит мне и покажет как это делается.Заранее очень извиняюсь ,если своим кодом затрону чьи-то чувства .Собственно:
Листинг программы
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ConsoleApplication2
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. figura s = new pervcl();
  13. s.treygolnic();
  14. s.pltreyg();
  15. s.kvadrat();
  16. s.perimkvadr();
  17. }
  18. }
  19. interface figura
  20. {
  21. void treygolnic();
  22. void pltreyg();
  23. void kvadrat();
  24. void perimkvadr();
  25. }
  26. class pervcl : figura
  27. {
  28. double l;
  29. double x;
  30. double p;
  31. double r;
  32. double s;
  33. double y;
  34. double u;
  35. double q;
  36. void figura.treygolnic()
  37. {
  38. Console.WriteLine("1)Значения треугольника:\nВведите x");
  39. this.x = Convert.ToInt32(Console.ReadLine());
  40. Console.WriteLine("Введите y");
  41. this.y = Convert.ToInt32(Console.ReadLine());
  42. Console.WriteLine("Введите l");
  43. this.l = Convert.ToInt32(Console.ReadLine());
  44. this.p = (x + y + l) / 2;
  45. Console.WriteLine("Введите r");
  46. this.r = Convert.ToInt32(Console.ReadLine());
  47. this.s = p * r;
  48. }
  49. void figura.pltreyg()
  50. {
  51. Console.Write("Площадь треугольника = {0} ", s);
  52. Console.ReadLine();
  53. }
  54.  
  55. class vtorclpervcl : pervcl, figura
  56. {
  57. void figura.kvadrat()
  58. {
  59. Console.WriteLine("\n2)Введите сторону квадратa a ");
  60. this.q = Convert.ToInt32(Console.ReadLine());
  61. this.u = q * 4;
  62. }
  63. void figura.perimkvadr()
  64. {
  65. Console.WriteLine("Периметр квадрата = {0}", u);
  66. Console.ReadLine();
  67. Console.ReadKey();
  68. }
  69. }
  70. }
  71. }

Решение задачи: «Класс не реализует член интерфейса»

textual
Листинг программы
  1. public class Program
  2. {
  3.     private static void Main(string[] args)
  4.     {
  5.  
  6.         figura s = new vtorclpervcl();
  7.         s.treygolnic();
  8.         s.pltreyg();
  9.         s.kvadrat();
  10.         s.perimkvadr();
  11.     }
  12.  
  13.     interface figura
  14.     {
  15.  
  16.         void treygolnic();
  17.         void pltreyg();
  18.         void kvadrat();
  19.         void perimkvadr();
  20.  
  21.     }
  22.  
  23.     abstract class pervcl : figura
  24.     {
  25.         protected double l;
  26.         protected double x;
  27.         protected double p;
  28.         protected double r;
  29.         protected double s;
  30.         protected double y;
  31.         protected double u;
  32.         protected double q;
  33.  
  34.         public void treygolnic()
  35.         {
  36.             Console.WriteLine("1)Значения треугольника:\nВведите  x");
  37.             this.x = Convert.ToInt32(Console.ReadLine());
  38.             Console.WriteLine("Введите y");
  39.             this.y = Convert.ToInt32(Console.ReadLine());
  40.             Console.WriteLine("Введите l");
  41.  
  42.             this.l = Convert.ToInt32(Console.ReadLine());
  43.             this.p = (x + y + l) / 2;
  44.             Console.WriteLine("Введите r");
  45.             this.r = Convert.ToInt32(Console.ReadLine());
  46.             this.s = p * r;
  47.         }
  48.         public void pltreyg()
  49.         {
  50.  
  51.             Console.Write("Площадь треугольника = {0}   ", s);
  52.             Console.ReadLine();
  53.         }
  54.  
  55.         public abstract void kvadrat();
  56.         public abstract void perimkvadr();
  57.     }
  58.  
  59.     class vtorclpervcl : pervcl
  60.     {
  61.         public override void kvadrat()
  62.         {
  63.             Console.WriteLine("\n2)Введите сторону квадратa a ");
  64.             this.q = Convert.ToInt32(Console.ReadLine());
  65.             this.u = q * 4;
  66.  
  67.         }
  68.         public override void perimkvadr()
  69.         {
  70.             Console.WriteLine("Периметр квадрата = {0}", u);
  71.             Console.ReadLine();
  72.             Console.ReadKey();
  73.         }
  74.     }
  75. }

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

5   голосов , оценка 3.4 из 5

Нужна аналогичная работа?

Оформи быстрый заказ и узнай стоимость

Бесплатно
Оформите заказ и авторы начнут откликаться уже через 10 минут
Похожие ответы