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 prezme
- {
- 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 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