Esempio n. 1
0
        /* OPPGAVE D */
        public Ståbillett[] KjøpBillett(int antVoksne, int antBarn)
        {
            KeyValuePair <bool, Ståbillett> kanSelge = this.SelgPlasser(antBarn + antVoksne);
            int antall = antBarn + antVoksne;

            if (kanSelge.Key)
            {
                Ståbillett[] temp = new Ståbillett[antall];
                for (int i = 0; i < antVoksne; i++)
                {
                    /*legger til billetter for voksne*/
                    //SelgPlasser(antVoksne - i);
                    temp[i] = new Ståbillett(this.Navn, this.Pris);
                    /* OPPGAVE D: ØKER INNTEKTENE MED BARNE PRIS MED HVER REGISTRERTE VOKSNEBILLETT*/
                    inntekt += temp[i].pris;
                }
                for (int j = antVoksne; j < temp.Length; j++)
                {
                    /* legger til billetter for barn med barnepris */
                    temp[j] = new Ståbillett(this.Navn, this.Barnepris);
                    /* OPPGAVE D: ØKER INNTEKTENE MED BARNE PRIS MED HVER REGISTRERTE BARNEBILLETT*/
                    inntekt += temp[j].pris;
                }
                Console.WriteLine("[" + this.Navn + "]: Kvittering: " + antall + " billetter solgt");
                return(temp);
            }
            else
            {
                Console.WriteLine("[" + this.Navn + "]: Oppgitt antall (" + antall + ") billetter kan ikke selges");
                return(null);
            }
        }
Esempio n. 2
0
        /* OPPGAVE D */
        override public Billett[] KjøpBillett(int antVoksne, int antBarn)
        {
            KeyValuePair <bool, Ståbillett> kanSelge = this.SelgPlasser(antBarn + antVoksne);
            int antall = antBarn + antVoksne;

            if (kanSelge.Key)
            {
                Billett[] temp = new Ståbillett[antall];
                for (int i = 0; i < antVoksne; i++)
                {
                    /*legger til billetter for voksne*/
                    //SelgPlasser(antVoksne - i);
                    temp[i]  = new Ståbillett(this.Navn, this.Pris);
                    inntekt += temp[i].pris;
                }
                for (int j = antVoksne; j < temp.Length; j++)
                {
                    /* legger til billetter for barn med barnepris */
                    temp[j]  = new Ståbillett(this.Navn, this.Barnepris);
                    inntekt += temp[j].pris;
                }
                Console.WriteLine("[" + this.Navn + "]: Kvittering: " + antall + " billetter solgt");
                return(temp);
            }
            else
            {
                Console.WriteLine("[" + this.Navn + "]: Oppgitt antall (" + antall + ") billetter kan ikke selges");
                return(null);
            }
        }