using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
namespace
OOPToo
{
//pärilus
class Maadleja {
protected int pikkus;
public Maadleja(int upikkus) //Ülekate
{
pikkus = upikkus;
}
public virtual void ytlepikkus()
{
Console.WriteLine("Minu pikkus on" + pikkus + "sentimeetrit");
}
protected int ymberm66t;
protected int kaal;
protected int vanus;
public Maadleja(int uvanus, int ukaal, int uymberm66t, int upikkus)
{
kaal = ukaal;
ymberm66t = uymberm66t;
vanus = uvanus;
}
public void MaadlejaEsitleb()
{
Console.WriteLine("Tere ma olen sportlane ja siin on minu mõõtmed");
Console.WriteLine("Mu ümberm66duks on " + ymberm66t + " sentimeetrit");
{
Console.WriteLine("Minu kaal on " + kaal + " Kilogrammi");
}
{
Console.WriteLine("Minu vanus on " + vanus + " aastat");
}
}
}
//liidesed
interface IViisakas
{
void NoorMaadleja(string AlgajaMaadleja);
void Tiitlitearv(int Tiitlitearv);
}
class NoorMaadleja : Treener, IViisakas
{
public void AlgajaMaadleja(String NoorMaadleja)
{
Console.WriteLine("Tere olen alles " + NoorMaadleja );
}
public void Tiitlitearv(int tiitlit)
{
Console.WriteLine("mul on 0" + tiitlit);
}
}
class Treener : Maadleja
{
protected int pikkus;
public Treener(int upikkus) //Ülekate
{
pikkus = upikkus;
}
public virtual void ytlepikkus()
{
Console.WriteLine("Minu pikkus on" + pikkus + "sentimeetrit");
}
protected int vanus;
protected int ymberm66t;
protected int Kaal;
public Treener(int uvanus, int uymberm66t, int uKaal)
:
base(uKaal, uymberm66t, uvanus)
{
vanus = uvanus;
Kaal = uKaal;
ymberm66t = uymberm66t;
}
public void TreenerEsitleb()
{
Console.WriteLine("Tere olen treener ja siin on minu näitajad");
Console.WriteLine("Minu ümberm66duks on " + ymberm66t + " sentimeetrit");
Console.WriteLine("Minu vanus on " + vanus + " aastat");
Console.WriteLine("Minu kaal on " + Kaal + " Kilogrammi");
Console.WriteLine("Minu pikkus on " + pikkus + " sentimeetrit");
}
}
class program
{
public static void Main(string[] arg)
{
Maadleja m = new Maadleja(20, 120, 150);
m.MaadlejaEsitleb();
Treener n = new Treener(50, 105, 100);
n.TreenerEsitleb();
}
}
}
VulpesPosted Jan 10, 2014, 11:05 AM
Normally, you could deal with this error by adding code on these lines to the NoorMaddleja class:
// add your code
}
However, you've made life difficult for yourself by giving the class the same name as the interface member it needs to implement and you're not allowed to use a constructor to implement an interface member.
To deal with this dilemma, I'd change the name of the interface method to something else and then implement this method in your NoorMaadleja class.