Guest User

Untitled

a guest
Aug 14th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.06 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Console.Write("Unesite broj soba: ");
  13.             int sobe = Convert.ToInt16(Console.ReadLine());
  14.  
  15.             Console.Write("Unesite broj brSpratova: ");
  16.             int spratovi = Convert.ToInt16(Console.ReadLine());
  17.  
  18.             Console.Write("Unesite cenu: ");
  19.             int Cena = Convert.ToInt16(Console.ReadLine());
  20.  
  21.             Kuca x = new Kuca(sobe, spratovi, Cena);
  22.            
  23.             Kuca.Dobrodoslica();
  24.  
  25.             x.Luksuz('d');
  26.             x.ispis();
  27.  
  28.             Console.ReadLine();
  29.  
  30.         }
  31.     }
  32.     class Kuca
  33.     {
  34.         private int brSoba;
  35.         private int brSpratova;
  36.         private int cena;
  37.  
  38.         public Kuca(int brSoba, int brSpratova, int cena)
  39.         {
  40.             this.brSoba = brSoba;
  41.  
  42.             /* Ja bih to ovako uradio:
  43.             if(brSpratova <= 0)
  44.                 this.brSpratova = 1;
  45.             else
  46.                 this.brSpratova = brSpratova;
  47.             */
  48.  
  49.             this.brSpratova = brSpratova;
  50.             this.cena = cena;
  51.         }
  52.         public static void Dobrodoslica()
  53.         {
  54.             Console.WriteLine("\nDobrodosli u agenciju za nekretnine");
  55.         }
  56.         public void ispis()
  57.         {
  58.             Console.WriteLine("Broj soba: " + brSoba);
  59.             Console.WriteLine("Broj brSpratova: " + brSpratova);
  60.             Console.WriteLine("Cena: " + cena);
  61.         }
  62.         public void Luksuz(char x)
  63.         {
  64.             if (x == 'd')
  65.                 cena = cena + 1000;
  66.         }
  67.         public int BrSpratova // ne razumem koji ce joj ovo ***** kada nista ne radi.
  68.         {
  69.             get { return this.brSpratova; }            
  70.             set
  71.             {
  72.                 if(value == 0)
  73.                     this.brSpratova = 1;
  74.                 else
  75.                     this.brSpratova = value;
  76.             }
  77.         }
  78.     }
  79. }
Add Comment
Please, Sign In to add comment