Advertisement
VictoriaLodochkina

lab 2 z1 sharp

Sep 16th, 2021
938
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. class Exam {
  5.     private string name;
  6.     private string date;
  7.     private int mark;
  8.     private string text="";
  9.    
  10.     public Exam() {
  11.         text="Construct without params for "+this.ToString();
  12.         Console.WriteLine(text);
  13.     }
  14.    
  15.     public Exam(string name, string date, int mark) {
  16.         this.name=name;
  17.         this.date=date;
  18.         this.mark=mark;
  19.         text="Construct with params for "+this.ToString();
  20.         Console.WriteLine(text);
  21.     }
  22.    
  23.     public Exam(Exam ex){
  24.         this.name=ex.name;
  25.         this.date=ex.date;
  26.         this.mark=ex.mark;
  27.         text="Copy construct for "+this.ToString();
  28.         Console.WriteLine(text);
  29.     }
  30.    
  31.     public string GetName(){
  32.         return this.name;
  33.     }
  34.    
  35.     public int GetMark(){
  36.         return this.mark;
  37.     }
  38.    
  39.     public string GetDate(){
  40.         return this.date;
  41.     }
  42.    
  43.     ~Exam() {
  44.         text="Destruct for "+this.ToString();
  45.         Console.WriteLine(text);
  46.     }
  47.    
  48. }
  49. class HelloWorld {
  50.   static void Main() {
  51.     //Console.WriteLine("Hello World");
  52.     Exam[] mas=new Exam[4];
  53.     for (int i=0; i<4; i++){
  54.         mas[i]=new Exam("student"+i.ToString(), (i+1).ToString()+".09.2021", 4);
  55.     }
  56.     Console.WriteLine(mas[2].GetName()+" "+mas[2].GetDate()+" "+(mas[2].GetMark()).ToString());
  57.    
  58.   }
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement