Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using geom;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("hello");
- Pont p1 = new Pont(4, 5, "fekete");
- Console.WriteLine("({0}, {1})", p1.X, p1.Y);
- //###
- //Console.WriteLine("({0}, {1})", p1.getX(), p1.getY());
- //p1.setX(-3);
- //Console.WriteLine("({0}, {1})", p1.getX(), p1.getY());
- Pont p2 = new Pont();
- //Console.WriteLine("({0}, {1}), {2}", p1.X, p1.Y, p1.Szin);
- //p1.X = -3
- Console.WriteLine("({0}, {1}), {2}", p1.X, p1.Y, p1.Szin);
- Console.WriteLine(p1.ToString());
- Console.WriteLine(p2);
- Pont p3 = new Pont();
- if (p2.Equals(p3))
- Console.WriteLine("egyenlő");
- else
- Console.WriteLine("nem egyenlő");
- Console.WriteLine("{0,5}, {1,-6:F1}{2}", "alma", 4.56, 'x');
- string sor = Console.ReadLine();
- int x = int.Parse(sor);
- Console.WriteLine(x);
- }
- }
- }
- //Class1.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace geom
- {
- class Pont
- {
- private int x, y;
- public int X
- {
- get
- {
- return x;
- }
- set
- {
- x = value;
- }
- }
- public int Y
- {
- get
- {
- return y;
- }
- set
- {
- y = value;
- }
- }
- public string Szin { get; private set; }
- public Pont(int x, int y, string szin)
- {
- this.x = x;
- this.y = y;
- Szin = szin;
- }
- public Pont(int x, int y) : this(x, y, "feher")
- {
- }
- public Pont() : this(0, 0)
- {
- }
- //public int getX()
- //{
- // return x;
- //}
- //public int getY()
- //{
- // return y;
- //}
- //public void setX(int x)
- //{
- // this.x = x;
- //}
- //public void setY(int y)
- //{
- // this.y = y;
- //}
- public override string ToString()
- {
- return "(" + x + ", " + y + ")" + Szin;
- }
- public override bool Equals(object obj)
- {
- Pont other = obj as Pont; //0-at ad vissza ha nem ugyanolyan tipusu
- return other != null && x == other.x && y == other.y && Szin.Equals(other.Szin); // szin-hez is mehet == Equals helyett
- //if (obj == null)
- // return false;
- //if (!(obj is Pont))
- // return false;
- //Pont other = (Pont)obj;
- //if (x != other.x)
- // return false;
- //if (y != other.y)
- // return false;
- //if (!Szin.Equals(other.Szin))
- // return false;
- //return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement