Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.33 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace ConsoleApp2
  5. {
  6.  
  7.     //student class
  8.     class Student
  9.     {
  10.         public string s_id;
  11.         public string s_name;
  12.  
  13.         public void setS_id(String s_id)
  14.         {
  15.             this.s_id = s_id;
  16.         }
  17.         public string getS_id()
  18.         {
  19.             return this.s_id;
  20.         }
  21.  
  22.         public void setS_name(String s_name)
  23.         {
  24.             this.s_name = s_name;
  25.         }
  26.         public string getS_name()
  27.         {
  28.             return this.s_name;
  29.         }
  30.  
  31.     }
  32.  
  33.  
  34.  
  35.     //book class
  36.  
  37.     class Book
  38.     {
  39.         public string isbn;//book id
  40.         public string title;// book title
  41.         public  string author;
  42.         public string subject;
  43.         public string shelf_id;//shelf number
  44.         public string shelf_author;
  45.  
  46.         //getter / setter
  47.  
  48.         public void setTile(String title)
  49.         {
  50.             this.title = title;
  51.         }
  52.         public string getTile()
  53.         {
  54.             return this.title;
  55.         }
  56.  
  57.  
  58.  
  59.     }
  60.  
  61.     class Student_Card
  62.     {
  63.         public string card_id;
  64.         public Student student;
  65.  
  66.         public void setStudent(Student student)
  67.         {
  68.             this.student = student;
  69.         }
  70.  
  71.  
  72.  
  73.     }
  74.  
  75.     //library
  76.     class Library
  77.     {
  78.           public  string name;
  79.         public string librarian_name;
  80.         public List<Student> borrowerlist = new List<Student>();
  81.  
  82.  
  83.         public void createLibrarian(string librarian_name)
  84.         {
  85.             this.librarian_name = librarian_name;
  86.         }
  87.  
  88.         public void student_enroll(Student stdt, Student_Card demo_crad)
  89.         {
  90.             demo_crad.setStudent(stdt);
  91.         }
  92.  
  93.         public void giveBook(Student_Card card)
  94.         {
  95.             borrowerlist.Add(card.student);
  96.         }
  97.  
  98.         public void showList()
  99.         {
  100.             foreach (Student std in borrowerlist)
  101.             {
  102.                 Console.WriteLine("Name: " + std.getS_name());
  103.             }
  104.         }
  105.  
  106.  
  107.  
  108.     }
  109.  
  110.  
  111.     class Program
  112.     {
  113.         static void Main(string[] args)
  114.         {
  115.             Console.WriteLine("Staring app.....");
  116.  
  117.             Library iubatLib = new Library();
  118.             iubatLib.name = "IUBAT Library";
  119.             iubatLib.createLibrarian("Mimma");
  120.             //done creteing Library
  121.             Student toma = new Student();
  122.             toma.s_id = "18103081";
  123.             toma.setS_name("Toma ");
  124.  
  125.             Student toma2 = new Student();
  126.             toma2.s_id = "181030821";
  127.             toma2.setS_name("Toma2 ");
  128.  
  129.  
  130.             //student card creating
  131.  
  132.             Student_Card card1 = new Student_Card();
  133.             card1.card_id = "card 1";
  134.             card1.setStudent(toma);
  135.            
  136.             Student_Card card2 = new Student_Card();
  137.             card2.card_id = "card 2";
  138.             card1.setStudent(toma2);
  139.  
  140.  
  141.             //book create
  142.             Book b = new Book();
  143.             b.isbn = "123";
  144.             b.title = "Liluya batas";
  145.             b.author = "Humayun Ahmed";
  146.             b.subject = "Nobel";
  147.             b.shelf_id = "321";
  148.             b.shelf_author = "tama";
  149.  
  150.             iubatLib.giveBook(card1);
  151.             iubatLib.giveBook(card2);
  152.             //show the list
  153.             iubatLib.showList();
  154.  
  155.         }
  156.     }
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement