Advertisement
kanagara

Untitled

Jun 20th, 2020
1,005
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. public class Predmet
  2. {
  3.   public int ocena;
  4. }
  5.    
  6. public static void Main(String[] args)
  7. {  
  8.     Predmet predmet = new Predmet();
  9.     //Za ocenu je unesen nevalidan podatak, ali nemamo nikakav mehanizam preko kog mozemo da sprecimo pogresan unos
  10.     predmet.ocena = 11;
  11. }
  12.  
  13.  
  14. public class Predmet
  15. {
  16.     private int ocena;
  17.    
  18.     public void SetOcena(int ocena){
  19.         if(ocena < 5 && ocena < 10) return;
  20.         this.ocena = ocena;
  21.     }
  22. }
  23.  
  24. public static void Main(String[] args){
  25.    
  26.     Predmet predmet = new Predmet();
  27.     //Unesen je neispravan podatak, ali nece narusiti integritet informacionog sistema jer smo u samoj klasi sprecili prosledjivanje neispravnog unosa
  28.     predmet.SetOcena(11);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement