Advertisement
ntamas

téglalap

Oct 19th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.   class Elso
  9.   {
  10.     protected int a, b;
  11.     public void Be_a(int x)
  12.     {
  13.       a = x;
  14.     }
  15.     public void Be_b(int x)
  16.     {
  17.       b = x;
  18.     }
  19.     public void Be_ab(int x, int y)
  20.     {
  21.       a = x;
  22.       b = y;
  23.     }
  24.     public int Ki_a()
  25.     {
  26.       return a;
  27.     }
  28.     public int Ki_b()
  29.     {
  30.       return b;
  31.     }
  32.     public int Kerulet()
  33.     {
  34.       return 2 * (a + b);
  35.     }
  36.   }
  37.   class Masodik : Elso
  38.   {
  39.     public int Kerulet()
  40.     {
  41.       return a + b;
  42.     }
  43.   }
  44.   class Program
  45.   {
  46.     static void Main(string[] args)
  47.     {
  48.       List<Masodik> teglalap = new List<Masodik>();
  49.       int? akarmi = 3;
  50.       for (int i = 0; i < 5; i++)
  51.       {
  52.         Masodik x = new Masodik();
  53.         x.Be_ab(i + 1, i + 1);
  54.         teglalap.Add(x);
  55.       }
  56.       foreach (Masodik x in teglalap)
  57.       {
  58.         Console.WriteLine(x.Kerulet());
  59.       }
  60.       Console.ReadKey();
  61.      
  62.     }
  63.   }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement