Menu



Manage

Study_C# > 6/Point.cs Lines 67 | 1.3 KB
다운로드

                        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;
        }

        public void setY(int y)
        {
            this.y = y;
        }

        public int GetX()
        {
            return this.x;
        }

        public int GetY()
        {
            return this.y;
        }
        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.GetX();
        this.y += pOffset.GetY();
    }
}
}