Advertisement
Levi0227

6. hét

Oct 18th, 2023 (edited)
549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.35 KB | Source Code | 0 0
  1. namespace _6het
  2. {
  3.     //class Auto
  4.     //{
  5.     //    public string rendszam;
  6.     //    int km;
  7.  
  8.     //    public Auto()
  9.     //    {
  10.     //        km = 0;
  11.     //    }
  12.  
  13.     //    public void Megy(int km)
  14.     //    {
  15.     //        this.km += km;
  16.     //    }
  17.  
  18.     //    public int Oraallas()
  19.     //    {
  20.     //        return km;
  21.     //    }
  22.     //}
  23.  
  24.  
  25.  
  26.     internal class _6het
  27.     {
  28.         static void Main(string[] args)
  29.         {
  30.             //Auto kocsi1 = new Auto();
  31.             //kocsi1.rendszam = "AA-BB-123";
  32.             //Console.WriteLine(kocsi1.rendszam);
  33.  
  34.             //kocsi1.Megy(10);
  35.             //Console.WriteLine(kocsi1.Oraallas()+"km");
  36.  
  37.  
  38.  
  39.             //Book b1 = new Book("szerzo1", "cim1", 2023, 100);
  40.             //Book b2 = new Book("J.R.R. Tolkien", "The Hobbit - or There and Back Again", 1937, 312);
  41.             //Console.WriteLine(b1.AllData()+"\n"+b2.AllData());
  42.  
  43.  
  44.  
  45.             //Runner r1 = new Runner("Janos", 2, 3);
  46.             //Runner r2 = new Runner("Péter", 4, 4);
  47.             //Runner r3 = new Runner("Gábor", 8, 2);
  48.  
  49.             //int cel = 30;
  50.             //while (r2.GetDistance() < cel && r1.GetDistance() < cel && r3.GetDistance() < cel)
  51.             //{
  52.             //    Console.Clear();
  53.             //    r1.RefreshDistance(1);
  54.             //    r2.RefreshDistance(1);
  55.             //    r3.RefreshDistance(1);
  56.             //    r1.Show();
  57.             //    r2.Show();
  58.             //    r3.Show();
  59.             //    System.Threading.Thread.Sleep(100);
  60.             //}
  61.  
  62.  
  63.  
  64.             //Caesar c1 = new Caesar(3);
  65.  
  66.             //string eredeti = "alma";
  67.             //string titkositott = c1.Encode(eredeti);
  68.             //string dekodolt = c1.Decode(titkositott);
  69.             //Console.WriteLine(titkositott + "\n" + dekodolt);
  70.  
  71.  
  72.  
  73.             Teglalap t1 = new Teglalap(4, 3, ConsoleColor.Yellow);
  74.             t1.Draw(0,0);
  75.         }
  76.     }
  77. }
  78.  
  79.  
  80.  
  81. //Class Book
  82. namespace _6het
  83. {
  84.     internal class Book
  85.     {
  86.         string szerzo;
  87.         string cim;
  88.         int kiadasEve;
  89.         int oldalSzam;
  90.  
  91.         public Book(string szerzo, string cim, int kiadasEve, int oldalSzam)
  92.         {
  93.             this.szerzo = szerzo;
  94.             this.cim = cim;
  95.             this.kiadasEve = kiadasEve;
  96.             this.oldalSzam = oldalSzam;
  97.         }
  98.  
  99.         public string AllData()
  100.         {
  101.             return $"{this.szerzo}: {this.cim}, {this.kiadasEve} ({this.oldalSzam} pages)";
  102.         }
  103.     }
  104. }
  105.  
  106.  
  107.  
  108. //Class Runner
  109. using System;
  110. using System.Collections.Generic;
  111. using System.Linq;
  112. using System.Text;
  113. using System.Threading.Tasks;
  114.  
  115. namespace _6het
  116. {
  117.     internal class Runner
  118.     {
  119.         string nev;
  120.         int sorszam;
  121.         int sebesseg;
  122.         int tavolsag;
  123.  
  124.         public Runner(string nev, int sorszam, int sebesseg)
  125.         {
  126.             this.nev = nev;
  127.             this.sorszam = sorszam;
  128.             this.sebesseg = sebesseg;
  129.             this.tavolsag = 0;
  130.         }
  131.  
  132.         public void RefreshDistance(int mp)
  133.         {
  134.             tavolsag += sebesseg * mp;
  135.         }
  136.  
  137.         public void Show()
  138.         {
  139.             Console.SetCursorPosition(tavolsag, sorszam);
  140.             Console.WriteLine(nev[0]);
  141.         }
  142.  
  143.         public int GetDistance()
  144.         {
  145.             return tavolsag;
  146.         }
  147.     }
  148. }
  149.  
  150.  
  151.  
  152. //Class Ceasar
  153. namespace _6het
  154. {
  155.     internal class Caesar
  156.     {
  157.         int kulcs;
  158.  
  159.         public Caesar(int kulcs)
  160.         {
  161.             this.kulcs = kulcs;
  162.         }
  163.  
  164.         private string TransformMessage(string uzenet, int kulcs)
  165.         {
  166.             string message = "";
  167.             for (int i = 0; i < uzenet.Length; i++)
  168.             {
  169.                 int szam = (int)uzenet[i];
  170.                 szam += kulcs;
  171.                 char betu = (char)szam;
  172.                 message += betu;
  173.             }
  174.             return message;
  175.         }
  176.  
  177.         public string Encode(string uzenet)
  178.         {
  179.             return TransformMessage(uzenet, kulcs);
  180.         }
  181.         public string Decode(string uzenet)
  182.         {
  183.             return TransformMessage(uzenet, -kulcs);
  184.         }
  185.     }
  186. }
  187.  
  188.  
  189.  
  190. //Class teglalap
  191. namespace _6het
  192. {
  193.     internal class Teglalap
  194.     {
  195.         int szelesseg;
  196.         int magassag;
  197.         ConsoleColor szin;
  198.  
  199.         public Teglalap(int szelesseg, int magassag, ConsoleColor szin)
  200.         {
  201.             this.szelesseg = szelesseg;
  202.             this.magassag = magassag;
  203.             this.szin = szin;
  204.         }
  205.  
  206.         private int Area()
  207.         {
  208.             return szelesseg * magassag;
  209.         }
  210.  
  211.         public bool IsValid()
  212.         {
  213.             if (Area() > 0)
  214.             { return true; }
  215.             //else { return false; }
  216.             return false;
  217.         }
  218.  
  219.         public void Draw(int x, int y)
  220.         {
  221.             string C = "@";
  222.             Console.ForegroundColor = szin;
  223.  
  224.             string[,] negyzet = new string[magassag, szelesseg - 1];
  225.             Console.SetCursorPosition(0, x);
  226.  
  227.             for (int i = 0; i < negyzet.GetLength(0); i++)
  228.             {
  229.                 for (int c = 0; c < y; c++) Console.Write(" ");
  230.  
  231.                 for (int j = 0; j <= negyzet.GetLength(1); j++)
  232.                 {
  233.                     Console.Write(C);  
  234.                 }
  235.                 Console.WriteLine();
  236.             }
  237.         }
  238.     }
  239. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement