Advertisement
Guest User

Untitled

a guest
Jan 25th, 2015
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. public class Class
  2.  
  3. {
  4.  
  5.     public string Letter { get; set; }
  6.  
  7.     public int Number { get; set; }
  8.  
  9.     public Class (int number, string letter) { this.Letter = letter; this.Number = number; }
  10.  
  11. }
  12.  
  13. public class Student
  14.  
  15. {
  16.  
  17.     public string Name { get; set; }
  18.  
  19.     public Class Class { get; set; }
  20.  
  21.     public int NumberInClass { get; set; }
  22.  
  23.     public string UniqueClassNumber
  24.  
  25.     {
  26.  
  27.         get
  28.  
  29.         {
  30.  
  31.             return this.Class.Number + this.Class.Letter + this.NumberInClass
  32.  
  33.         }
  34.  
  35.     }
  36.  
  37.     public Student (string name, int number, Class class) { ... }
  38.  
  39. }
  40.  
  41.  
  42.  
  43. И съответно
  44.  
  45. Class c = new Class(11, "a");
  46.  
  47. Student pesho = new Student("pesho", 16, c);
  48.  
  49. Console.WriteLine(pesho.UniqueNumber); // 11a16
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement