Bonjour,
j'ai implémenté ceci :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Rayan2
{
class Publication
{
private String title;
private int sale;
private float price;
private int participation;
public String Title
{
get
{
return title;
}
set
{
title = value;
}
}
public int Sale
{
get
{
return sale;
}
set
{
sale = value;
}
}
public float Price
{
get
{
return price;
}
set
{
price = value;
}
}
public int Participation
{
get
{
return participation;
}
set
{
participation = sale * price;
Console.WriteLine("price als float: {0}, price als int: {1}", price, (int)price);
}
}
public override string ToString()
{
return String.Format("{0}\n----------------------\nTitel : {1}\nVerkaufszahlen : {2}\nPreis pro Stück ($) : {3}\nBeteiligungssatz : {4} %", title, sale, price, participation);
}
public virtual float CalculateFee()
{
float calculatefee = (float)(sale * (int)price / 100 * participation);
return calculatefee;
}
}
class Book : Publication
{
private int pages;
public int Pages
{
get
{
return pages;
}
set
{
pages = value;
}
}
public override string ToString()
{
return String.Format("{0}\n----------------------\nTitel : {1}\nVerkaufszahlen : {2}\nPreis pro Stück ($) : {3}\nBeteiligungssatz : {4} %\nPages : {5}", title, sale, price, participation,pages);
}
}
abstract class DigitalMediaj : Publication
{
private const float literalPropertyFee = 10000;
private int runTime;
public DigitalMediaj(int runTime)
{
this.runTime = runTime;
}
public float LiteralPropertyFee
{
get
{
return LiteralPropertyFee;
}
}
private int RuntimeMedium{
get
{
return runTime ;
}
set
{
runTime = value ;
}
}
public override float CalculateFee()
{
float calculatefee = (float)((sale * (int)price / 100 * participation)+(int) LiteralPropertyFee);
return calculatefee;
}
}
class Audio : DigitalMediaj
{
}
public class Movie : DigitalMediaj
{
private float movieRights;
public float MovieRights
{
get
{
return MovieRights;
}
set
{
MovieRights = value;
}
}
public override float CalculateFee()
{
float calculatefee = (float)(((sale * (int)price / 100 * participation) + (int)LiteralPropertyFee)+(int)MovieRights);
return calculatefee;
}
public override string ToString()
{
return String.Format("{0}{1}{2}{3}{4}{5}{6}", title, sale, price, participation, LiteralPropertyFee,MovieRights);
}
}
}
En fait je dois implémenter la méhode CalculateFee() qu'une seule fois , c'est à dire dans la classe Publication dont hérite la class Book et la classe DigitalMediaj. Les classes Audio et Movie heritent de la classe DigitalMediaj. Comment devrais-je utiliser la méthode CalculateFee() dans les autres classes sans la dupliquer.
En plus il ya une erreur de compilation qui persiste: Inconsistent accessibility: base class 'Rayan2.DigitalMediaj' is less accessible than class 'Rayan2.Movie'
merci


