파일 목록
-
📁 10
-
📁 3
-
📁 4
-
📁 4-minicalc
-
📁 7
-
📁 parking manager
- 2.cs
- desktop.ini
- Title.png
- 객체지향 3대 특징(+1).txt
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace Week9ClassA
{
internal class Point //생성자로 만들면서 초기화하거나 메소드 이용
{
private int x;
private int y;
/// <summary>
/// 생성자: 인스턴스 생성시 초기화
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
//public void setX(int x)
//{
// this.x = x;
//}
////C#은 세터 게터 안써, 프로퍼티를 안해서 이걸하는거
//
//
//public void setY(int y)
//{
// this.y = y;
//}
//
//public int GetX()
//{
// return this.x;
//}
//
//public int GetY()
//{
// return this.y;
//}
//프로퍼티 = 속성 뒤에 괄호없는 중괄호 형태
//두개 구역 필요 get/ set
public int X //외부에서 취급은 변수지만, 입력 출력 하면 메서드임
{
get { //getter method
return this.x;
}
set { //setter method
this.x = value;
}
}
public int Y //외부에서 취급은 변수지만, 입력 출력 하면 메서드임
{
get
{ //getter method
return this.y;
}
set
{ //setter method
this.y = value;
}
}
public void AddX(int offset)
{
this.x += offset;
}
public void AddY(int offset)
{
this.y += offset;
}
public void AddXY(int xOffset, int yOffset)
{
this.x += xOffset;
this.y += yOffset;
}
public void AddXY(Point pOffset)
{
this.x += pOffset.X;
this.y += pOffset.Y;
}
}
}