mardi 28 novembre 2017

How can i check if a class has a atribute?

Need some help for homework. How do i check if a class has a atribute? the method reprodukujZvuk is overrided from a abstract class Racunarthe method there is virtual void.

class Desktop : Racunar
{
    public string zvucnaKartica { get; set; }

    public Desktop() { }
    public Desktop(double RAM, string grafickaKartica, string maticnaPloca, string procesor,string zvucnaKartica)
    {
        this.RAM = RAM;
        this.grafickaKartica = grafickaKartica;
        this.maticnaPloca = maticnaPloca;
        this.procesor = procesor;
        this.zvucnaKartica = zvucnaKartica;

    }
    public void Detalji()
    {
        Console.WriteLine("Desktop racunar:\n\nKolicina RAM-a: {0} gb\nModel Graficke kartice: {1}\nModel Maticne Ploce: {2}\nModel Procesora: {3}\nModel zvucne kartice:{4}", RAM, grafickaKartica, maticnaPloca, procesor,zvucnaKartica);
    }
    public override double cenaUredjaja()
    {
        Random rnd = new Random();
        return rnd.Next(500, 3789);
    }
    public override void reprodukujZvuk()
    {
       // in this method i need to check if in the class i have a atribute zvucnaKartica
        //if it does it needs to 
            Console.WriteLine("Biip");
        else
            Console.WriteLine("Reprodukcija zvuka nije moguca jer racunar nema zvucnu karticu");

    }

Aucun commentaire:

Enregistrer un commentaire