C# héritage
Résolu/Fermé
gilles81
Messages postés
67
Date d'inscription
mardi 20 mai 2008
Statut
Membre
Dernière intervention
29 juillet 2009
-
26 déc. 2008 à 08:05
gilles81 Messages postés 67 Date d'inscription mardi 20 mai 2008 Statut Membre Dernière intervention 29 juillet 2009 - 26 déc. 2008 à 12:26
gilles81 Messages postés 67 Date d'inscription mardi 20 mai 2008 Statut Membre Dernière intervention 29 juillet 2009 - 26 déc. 2008 à 12:26
A voir également:
- C# héritage
- Texte de don d'héritage ✓ - Forum Vos droits sur internet
- Maison héritage canapé avis - Forum Vos droits sur internet
- Cheick yvan formate héritage - Forum Vos droits sur internet
- Valise maison heritage avis ✓ - Forum Consommation & Internet
- Arnaque canapé ✓ - Forum Vos droits sur internet
2 réponses
scriptiz
Messages postés
1424
Date d'inscription
dimanche 21 décembre 2008
Statut
Membre
Dernière intervention
14 septembre 2023
425
26 déc. 2008 à 12:23
26 déc. 2008 à 12:23
Bon voilà j'ai apporter quelques modifications :
Sinon je te conseille de remplacer ceci :
Par ceci (étant donné que tu ne modifie jamais la valeur de la participation avec value.
Tu peux y rajouter ton affichage console et ainsi supprimer le _participation, comme ça tu aura toujours la valeur de Sale * Price quand tu demandera Participation.
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 = (int)(_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}", base.Title, base.Sale, base.Price, base.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() { return (base.CalculateFee() + (int)LiteralPropertyFee); } } class Audio : DigitalMediaj { } public class Movie : DigitalMediaj { private float _movieRights; public float MovieRights { get { return _movieRights; } set { _movieRights = value; } } public override float CalculateFee() { return (base.CalculateFee() + (int)MovieRights); } public override string ToString() { return base.ToString() + String.Format("{0}{1}", base.LiteralPropertyFee, MovieRights); } } }
Sinon je te conseille de remplacer ceci :
public int Participation { get { return _participation; } set { _participation = (int)(_sale * _price); Console.WriteLine("price als float: {0}, price als int: {1}", price, (int)price); } }
Par ceci (étant donné que tu ne modifie jamais la valeur de la participation avec value.
public int Participation { get { return (int)(Sale * Price); } }
Tu peux y rajouter ton affichage console et ainsi supprimer le _participation, comme ça tu aura toujours la valeur de Sale * Price quand tu demandera Participation.
gilles81
Messages postés
67
Date d'inscription
mardi 20 mai 2008
Statut
Membre
Dernière intervention
29 juillet 2009
1
26 déc. 2008 à 12:26
26 déc. 2008 à 12:26
merci