Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Клас Student
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net.NetworkInformation;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml.Linq;
- namespace DemoOOP
- {
- public class Student : Person
- {
- // Полета - Състояние
- private int Pin;
- private string Name;
- private string LastName;
- private double gradeBEL;
- public Student(int Pin, string Name, string LastName, double grade) : base(Pin, Name, LastName)
- {
- this.Pin = Pin;
- this.Name = Name;
- this.LastName = LastName;
- this.gradeBEL = grade;
- }
- // ctor с параметри)
- // Метод за изчисляване на средна оценка по два предмета
- public double CalcAvgGrade(double grade1, double grade2)
- {
- double avg = (grade1 + grade2)/2;
- return avg;
- }
- // Метод за принтиране данните на обект в конзолата
- public void PrintData()
- {
- Console.WriteLine(this.Pin);
- Console.WriteLine(this.Name);
- Console.WriteLine(this.LastName);
- Console.WriteLine(this.gradeBEL);
- }
- }
- }
- //==============================================
- Клас Person
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DemoOOP
- {
- public class Person
- {
- private int Pin;
- private string Name;
- private string LastName;
- public Person( int Pin, string Name, string LastName)
- {
- this.Pin = Pin;
- this.Name = Name;
- this.LastName = LastName;
- }
- }
- }
- //================================================
- // Клас Program
- namespace DemoOOP
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("==================================");
- Console.WriteLine("Created by ctor with parameters");
- Student student2 = new Student(1234567890, "Milena", "Damesova", 4.55);
- student2.PrintData();
- Console.WriteLine(student2.CalcAvgGrade(4.55, 6.00));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement