Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- public interface MyInterface
- {
- int Sum();
- int Otr();
- int Prz();
- int Del();
- }
- public interface ISqrSqrt
- {
- int Sqr(int x);
- int Sqrt(int x);
- string this[int index]
- {
- get;
- set;
- }
- }
- class First : MyInterface
- {
- string myName;
- int My_x, My_y;
- public int x
- {
- set { My_x = value; }
- get { return My_x; }
- }
- public int y
- {
- set { My_y = value; }
- get { return My_y; }
- }
- public First() { }
- public First(int x, int y)
- {
- this.x = x;
- this.y = y;
- }
- public virtual int Sum()
- {
- return x + y;
- }
- public int Otr()
- {
- return x - y;
- }
- public int Prz()
- {
- return x * y;
- }
- public int Del()
- {
- return x / y;
- }
- public string this[int index]
- {
- set { myName = value; }
- get { return myName; }
- }
- public virtual void rewrite()
- {
- Console.WriteLine("Переменная x: {0}\nПеременная y: {1}", x, y);
- }
- }
- class Second : First
- {
- public int z;
- public Second(int z, int x, int y)
- : base(x, y)
- {
- this.z = z;
- }
- public override int Sum()
- {
- return base.x + base.y + z;
- }
- public override void rewrite()
- {
- base.rewrite();
- Console.WriteLine("Переменная z: " + z);
- }
- }
- class Third : First, ISqrSqrt
- {
- public int Sqr(int x)
- {
- return x * x;
- }
- public int Sqrt(int x)
- {
- return (int)Math.Sqrt((double)(x));
- }
- }
- class Program
- {
- static void Main()
- {
- First obj1 = new First(x: 10, y: 12);
- obj1[5] = "Hello";
- Console.WriteLine("{0}", obj1[5]);
- Console.WriteLine("obj1: ");
- obj1.rewrite();
- Console.WriteLine("{0} + {1} = {2}", obj1.x, obj1.y, obj1.Sum());
- Console.WriteLine("{0} * {1} = {2}", obj1.x, obj1.y, obj1.Prz());
- Second obj2 = new Second(z: -3, x: 10, y: 14);
- Console.WriteLine("\nobj2: ");
- obj2.rewrite();
- Console.WriteLine("{0} + {1} + {3} = {2}", obj2.x, obj2.y, obj2.Sum(), obj2.z);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement