Advertisement
Guest User

Untitled

a guest
Nov 17th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace punkt
  8. {
  9.     class Punkt
  10.     {
  11.         int wspolrzednaX, wspolrzednaY;
  12.         public Punkt(int x, int y)
  13.         {
  14.             wspolrzednaX = x;
  15.             wspolrzednaY = y;
  16.         }
  17.         public void Przesuń(int ox, int oy)
  18.         {
  19.             wspolrzednaX += ox;
  20.             wspolrzednaY += oy;
  21.             Console.WriteLine("Przesunięto!");
  22.         }
  23.         public void Wyświetl()
  24.         {
  25.             Console.WriteLine("\nPunkt jest na wspolrzednych X:{0} Y:{1}", wspolrzednaX, wspolrzednaY);
  26.         }
  27.     }
  28.     class Program
  29.     {
  30.         static void Main(string[] args)
  31.         {
  32.             int x, y, ox, oy;
  33.             Console.Write("Podaj wspolrzedna X: ");
  34.             x = Int32.Parse(Console.ReadLine());
  35.             Console.Write("Podaj wspolrzedna Y: ");
  36.             y = Int32.Parse(Console.ReadLine());
  37.             Punkt p1 = new Punkt(x,y);
  38.             p1.Wyświetl();
  39.             Console.Write("\nPrzesuń na X: ");
  40.             ox = Int32.Parse(Console.ReadLine());
  41.             Console.Write("Przesuń na Y: ");
  42.             oy = Int32.Parse(Console.ReadLine());
  43.             p1.Przesuń(ox, oy);
  44.             p1.Wyświetl();
  45.             Console.ReadKey();
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement