-
September 29th, 2022, 05:07 AM
#1
Inheterence issue
/Error CS0534: 'AverageSummary' does not implement inherited abstract member 'SummaryStrategy.PrintSummary()' (CS0534) (Tk1)
I am not sure what the problem is and what it is that I am not doing
===============================
Code:
base class :
using System;
using System.Drawing;
namespace Tk1
{
public abstract class SummaryStrategy
{
public abstract void PrintSummary();
}
}
THE CHILD CLASS
Code:
using System;
namespace Tk1
{
public class AverageSummary:SummaryStrategy
{
private List<int> _asnumbers = new List<int>();
public float Average;
public AverageSummary(List<int> numbers)
{
Console.WriteLine("I am in AverageSummary");
double sum = 0;
foreach (var element in numbers)
{
sum += (double)element;
_asnumbers.Add(element);
}
var avg = sum / numbers.Count();
Average = (float)avg;
//PrintAverage(numbers);
}
public void PrintAverage()//(List<int> numbers)
{
}
}
}
THANK you
Using Java version on windows 1.8_51
-
October 5th, 2022, 12:33 AM
#2
Re: Inheterence issue
Originally Posted by Saeed
/Error CS0534: 'AverageSummary' does not implement inherited abstract member 'SummaryStrategy.PrintSummary()' (CS0534) (Tk1)
I am not sure what the problem is and what it is that I am not doing
You inherit the SummaryStrategy class into AverageSummary. It means AverageSummary is_a SummaryStrategy. But to be that, AverageSummary must implement all abstract methods of SummaryStrategy. Does it do that? No, It does not implement the PrintSummary() method. That is what the error message tells you.
Last edited by wolle; October 5th, 2022 at 01:06 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|