C#/수업 내용

[C#] 2021-08-25 오후

JSH1 2021. 8. 25. 17:26
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

class Program
{
    static void Main(string[] args)
    {
        Larva larva = new Larva();    //Larva클래스의 인스턴스
        Drone drone = larva.Transform("드론");
        Console.WriteLine(drone);
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Larva
{
    //생성자 메서드
    public Larva()
    {
        Console.WriteLine("Larva가 생성되었습니다.");
    }

    //메서드 정의
    public Drone Transform(string unit)
    {
        return new Drone(unit);
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Drone
{
    //생성자 메서드
    public Drone(string unit)
    {
        Console.WriteLine("{0}이 생성되었습니다.", unit);
    }
}

 

'C# > 수업 내용' 카테고리의 다른 글

[C#] 2021-08-26 오후  (0) 2021.08.26
[C#] 2021-08-26 오전  (0) 2021.08.26
[C#] class  (0) 2021.08.25
[C#] 2021-08-24 오후  (0) 2021.08.24
[C#] Method  (0) 2021.08.24