본문 바로가기

C#/수업 과제

클래스 및 인스턴스 만들기와 메서드 연습1 (라바-저글링)

메인메서드

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        Larva larva = new Larva();
        
        Zergling zergling = larva.Transform("저글링");
        Console.WriteLine(zergling);
    }
}

라바 클래스

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Larva
{
    //멤버 변수




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


    //멤버 메서드
    public Zergling Transform(string unitName)
    {
        Console.WriteLine("{0}(으)로 변태 합니다.", unitName);
        for (int i = 0; i < 1; i++)
        {
            return new Zergling();
        }
    }
}

저글링 클래스

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Zergling
{
    //멤버 변수




    //생성자 메서드
    public Zergling()
    {
        Console.WriteLine("저글링이 생성되었습니다.");
    }




    //멤버 메서드
}

두개 이상의 값을 반환하는 방법을 아직 모른다.