Moderator: xxSlayeRxx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Cwicznie_4_4
{
class Program
{
static void Main(string[] args)
{
Punkt punkt = new Punkt(); //Tworzę nowy obiekt "jakisTamPunkt" klasy Punkt
Punkt pomocniczyPunkt;
pomocniczyPunkt = punkt.PobierzWspolrzedne();
//Wyświetlam na ekranie wartości punktu 'x' oraz 'y' przed skorzystaniem z metody "UstawWspolrzedne"
Console.WriteLine("Przed ustawieniem wartości");
Console.WriteLine("Współrzędna x = " + pomocniczyPunkt.x);
Console.WriteLine("Współrzędna y = " + pomocniczyPunkt.y);
//Ustawienie współrzędnych za pomocą metody UstawWspolrzedne
punkt.UstawWspolrzedne(1, 2);
pomocniczyPunkt.PobierzWspolrzedne();
//Wyświetlam na ekranie wartości punktu 'x' oraz 'y' po skorzystaniu z metody "PobierzWspolrzedne"
Console.WriteLine("Po ustawieniu wartości");
Console.WriteLine("Współrzędna x = " + pomocniczyPunkt.x);
Console.WriteLine("Współrzędna y = " + pomocniczyPunkt.y);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Cwicznie_4_4
{
class Punkt
{
public int x;
public int y;
public void UstawWspolrzedne(int wspX, int wspY)
{
x = wspX;
y = wspY;
}
public Punkt PobierzWspolrzedne()
{
Punkt punkt = new Punkt();
punkt.x = x;
punkt.y = y;
return punkt;
}
}
}
Użytkownicy przeglądający ten dział: Brak zidentyfikowanych użytkowników i 8 gości