Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication5
- {
- class FudbalerU21
- {
- private string Ime;
- private string Prezime;
- private int _G_R;
- private int _B_G;
- public FudbalerU21(string ime, string prezime, int gr, int bg)
- {
- this.Ime = ime;
- this.Prezime = prezime;
- this._G_R = gr;
- this._B_G = bg;
- }
- public string ime
- {
- set
- {
- if (value == null || value == string.Empty) throw new Exception("No name provided");
- else this.Ime = value;
- }
- get
- {
- return this.Ime;
- }
- }
- public int BrojGolova
- { set; get; }
- public int GR
- { set; get; }
- public string prezime
- {
- set
- {
- if (value == null || value == string.Empty) throw new Exception("No lastname provided");
- else this.Prezime = value;
- }
- get
- {
- return this.Prezime;
- }
- }
- public bool DaLiJePunoljetan()
- {
- if (DateTime.Now.Year - GR == 21) return true; else return false;
- }
- public int godine
- {
- get
- {
- return (DateTime.Now.Year - this._G_R);
- }
- set
- {
- godine = DateTime.Now.Year - this._G_R;
- if (godine > 21) throw new Exception("hasjf");
- }
- }
- public void Ispisi()
- {
- if (21 - this.godine <= 0) throw new InvalidCastException("Fudbaler je punoljetan");
- Console.WriteLine(Ime + " " + Prezime + " " + _G_R + " Do punoljetnosti ostalo: {0} ", (21-this.godine));
- }
- }
- class Trener
- {
- string Ime;
- string Prezime;
- int _G_R;
- public Trener(string ime, string prezime, int GR)
- {
- this.Ime = ime;
- this.Prezime = prezime;
- this._G_R = GR;
- }
- public string ime
- {
- set
- {
- if (value == null || value == string.Empty) throw new Exception("No name provided");
- else this.Ime = value;
- }
- get
- {
- return this.Ime;
- }
- }
- public int GR
- { set; get; }
- public string prezime
- {
- set
- {
- if (value == null || value == string.Empty) throw new Exception("No lastname provided");
- else this.Prezime = value;
- }
- get
- {
- return this.Prezime;
- }
- }
- public int GodineIskustva
- {
- set
- {
- value++;
- }
- get
- {
- return GodineIskustva;
- }
- }
- }
- class Klub
- {
- private FudbalerU21[] klub;
- private string ImeKluba;
- private Trener Coach;
- public FudbalerU21 club
- {
- get;
- set;
- }
- public string IK
- {
- get; set;
- }
- public Klub(FudbalerU21[] niz, string ImeK, Trener tr)
- {
- klub = niz;
- ImeKluba = ImeK;
- Coach = tr;
- }
- public void Ispisi()
- {
- foreach (FudbalerU21 i in klub)
- Console.WriteLine(i.ime, i.prezime, i.BrojGolova) ;
- }
- public FudbalerU21 DajNajboljeg()
- {
- int max = 0;
- int ind=0;
- for (int i = 0; i < klub.Length; i++)
- {
- if (klub[i].BrojGolova > max)
- {
- max = klub[i].BrojGolova;
- ind = i;
- }
- }
- return klub[ind];
- }
- public int DajBodove()
- {
- int suma=0;
- for(int i=0; i<klub.Length; i++)
- suma+=klub[i].BrojGolova;
- return suma;
- }
- public void EvidentirajGolove(string ime)
- {
- for (int i = 0; i < klub.Length; i++)
- {
- if (klub[i].ime == ime)
- klub[i].BrojGolova++;
- }
- }
- }
- class NogometniSavez
- {
- private Klub[] NS;
- public void Ispisi()
- {
- for (int i = 0; i < NS.Length; i++)
- {
- for(int j=i+1; j<NS.Length; j++)
- {
- if(NS[i].DajBodove() > NS[j].DajBodove())
- {
- Klub temp=NS[i];
- NS[i]=NS[j];
- NS[j]=temp;
- }
- }
- }
- for(int i=0; i<NS.Length; i++)
- Console.WriteLine( NS[i].IK);
- }
- class Program
- {
- static void Main(string[] args)
- {
- try
- {
- FudbalerU21 NF = new FudbalerU21("Adin", "Velić", 1993, 1000);
- NF.Ispisi();
- }
- catch (InvalidCastException e )
- {
- Console.WriteLine(e);
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement