Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace _6het
- {
- //class Auto
- //{
- // public string rendszam;
- // int km;
- // public Auto()
- // {
- // km = 0;
- // }
- // public void Megy(int km)
- // {
- // this.km += km;
- // }
- // public int Oraallas()
- // {
- // return km;
- // }
- //}
- internal class _6het
- {
- static void Main(string[] args)
- {
- //Auto kocsi1 = new Auto();
- //kocsi1.rendszam = "AA-BB-123";
- //Console.WriteLine(kocsi1.rendszam);
- //kocsi1.Megy(10);
- //Console.WriteLine(kocsi1.Oraallas()+"km");
- //Book b1 = new Book("szerzo1", "cim1", 2023, 100);
- //Book b2 = new Book("J.R.R. Tolkien", "The Hobbit - or There and Back Again", 1937, 312);
- //Console.WriteLine(b1.AllData()+"\n"+b2.AllData());
- //Runner r1 = new Runner("Janos", 2, 3);
- //Runner r2 = new Runner("Péter", 4, 4);
- //Runner r3 = new Runner("Gábor", 8, 2);
- //int cel = 30;
- //while (r2.GetDistance() < cel && r1.GetDistance() < cel && r3.GetDistance() < cel)
- //{
- // Console.Clear();
- // r1.RefreshDistance(1);
- // r2.RefreshDistance(1);
- // r3.RefreshDistance(1);
- // r1.Show();
- // r2.Show();
- // r3.Show();
- // System.Threading.Thread.Sleep(100);
- //}
- //Caesar c1 = new Caesar(3);
- //string eredeti = "alma";
- //string titkositott = c1.Encode(eredeti);
- //string dekodolt = c1.Decode(titkositott);
- //Console.WriteLine(titkositott + "\n" + dekodolt);
- Teglalap t1 = new Teglalap(4, 3, ConsoleColor.Yellow);
- t1.Draw(0,0);
- }
- }
- }
- //Class Book
- namespace _6het
- {
- internal class Book
- {
- string szerzo;
- string cim;
- int kiadasEve;
- int oldalSzam;
- public Book(string szerzo, string cim, int kiadasEve, int oldalSzam)
- {
- this.szerzo = szerzo;
- this.cim = cim;
- this.kiadasEve = kiadasEve;
- this.oldalSzam = oldalSzam;
- }
- public string AllData()
- {
- return $"{this.szerzo}: {this.cim}, {this.kiadasEve} ({this.oldalSzam} pages)";
- }
- }
- }
- //Class Runner
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _6het
- {
- internal class Runner
- {
- string nev;
- int sorszam;
- int sebesseg;
- int tavolsag;
- public Runner(string nev, int sorszam, int sebesseg)
- {
- this.nev = nev;
- this.sorszam = sorszam;
- this.sebesseg = sebesseg;
- this.tavolsag = 0;
- }
- public void RefreshDistance(int mp)
- {
- tavolsag += sebesseg * mp;
- }
- public void Show()
- {
- Console.SetCursorPosition(tavolsag, sorszam);
- Console.WriteLine(nev[0]);
- }
- public int GetDistance()
- {
- return tavolsag;
- }
- }
- }
- //Class Ceasar
- namespace _6het
- {
- internal class Caesar
- {
- int kulcs;
- public Caesar(int kulcs)
- {
- this.kulcs = kulcs;
- }
- private string TransformMessage(string uzenet, int kulcs)
- {
- string message = "";
- for (int i = 0; i < uzenet.Length; i++)
- {
- int szam = (int)uzenet[i];
- szam += kulcs;
- char betu = (char)szam;
- message += betu;
- }
- return message;
- }
- public string Encode(string uzenet)
- {
- return TransformMessage(uzenet, kulcs);
- }
- public string Decode(string uzenet)
- {
- return TransformMessage(uzenet, -kulcs);
- }
- }
- }
- //Class teglalap
- namespace _6het
- {
- internal class Teglalap
- {
- int szelesseg;
- int magassag;
- ConsoleColor szin;
- public Teglalap(int szelesseg, int magassag, ConsoleColor szin)
- {
- this.szelesseg = szelesseg;
- this.magassag = magassag;
- this.szin = szin;
- }
- private int Area()
- {
- return szelesseg * magassag;
- }
- public bool IsValid()
- {
- if (Area() > 0)
- { return true; }
- //else { return false; }
- return false;
- }
- public void Draw(int x, int y)
- {
- string C = "@";
- Console.ForegroundColor = szin;
- string[,] negyzet = new string[magassag, szelesseg - 1];
- Console.SetCursorPosition(0, x);
- for (int i = 0; i < negyzet.GetLength(0); i++)
- {
- for (int c = 0; c < y; c++) Console.Write(" ");
- for (int j = 0; j <= negyzet.GetLength(1); j++)
- {
- Console.Write(C);
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement