본문 바로가기
c#/수업 과제

생성자 메서드 연습하기

by 이지훈26 2021. 8. 25.

 

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

class ZUGGLRING
{
    public ZUGGLRING()  //생성자
    {
        Console.WriteLine("저글링이 생산됩니다.");
    }
}


using System;
class Program
{

    static void Main(string[] args)
    {
        //라바 생성 되었습니다.
        //라바가 저글링 x2로 번퇴 합니다.
        //저글링이 생성 되었습니다.
        //저글링이 생성 되었습니다.

        LARVAR larvar = new LARVAR();
        LARVAR larvar2;
        larvar2 = new LARVAR();

        ZUGGLRING zUGGLRING = larvar.Tranceform("저글링");
        Console.WriteLine(zUGGLRING);
    }
}



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

class LARVAR
{
    public LARVAR()  //생성자
    {
        Console.WriteLine("라바가 생성되었습니다.");
    }
    public ZUGGLRING Tranceform(string name)
    {
        Console.WriteLine("{0}으로 변태합니다.", name);
        return new ZUGGLRING();
    }
}

 

 

 

 

using System;

namespace HelloWorld
{
    class Program
    {

        static void Main(string[] args)
        {

            HighTemplar highTemplar1 = new HighTemplar();
            HighTemplar highTemplar2 = new HighTemplar();

            highTemplar1.Fusion("아칸");
            Arcorn arcorn = new Arcorn();
            Console.WriteLine();
            
        }

    }
}


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

class HighTemplar
{

    public HighTemplar()
    {
        Console.WriteLine("하이템플러를 생성합니다.");
    }

    public Arcorn Fusion(string Hightemplar)
    {
        Console.WriteLine("결합합니다.");
        return new Arcorn();
    }
}




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

class Arcorn
{
    public Arcorn()
    {
        Console.WriteLine("아콘이 탄생하였습니다.");
    }
}

 

 

 

 

 

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

class SCV
{
    int Build;
    int attack;
    public SCV()
    {
        Console.WriteLine("SCV를 생성합니다.");
    }
    public Verlux verlux(string name)
    {
        Console.WriteLine("SCV가 {0}를 건설합니다.", name);
        return new Verlux();
    }
}


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

class Verlux
{
    public Verlux()
    {
        Console.WriteLine("베럭스가 생성되었습니다.");
    }
}


using System;

namespace HelloWorld
{
    class Program
    {

        static void Main(string[] args)
        {
            SCV scv;
            scv = new SCV();
            Verlux verlux = scv.verlux("베럭스");
            Console.WriteLine(verlux);

            
        }
    }
}

 

using System;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Vulture vulture;
            vulture = new Vulture();
            Mine mine = vulture.mine("마인");
            Console.WriteLine("mine");

        }
    }
}


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

class Vulture
{
    string install;
    public Vulture()
    {
        Console.WriteLine("벌쳐를 생성했습니다.");
    }
    public Mine mine(string name)
    {
        Console.WriteLine("벌쳐가 {0}을 설치했습니다.", name);
        return new Mine();
    }
}


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

class Mine
{
    
    public Mine()
    {
        Console.WriteLine("마인을 설치합니다.");
    }
    
}

 

 

using System;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Carrier carrier = new Carrier();

            for (int i = 0; i < 9; i++)
            {
                Console.WriteLine("인터셉트가 생성되었습니다.");
            }
        }
    }
}

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

class Intercept  //생성자 메서드
{
    public Intercept()
    {
        Console.WriteLine("인터셉트가 생성되었습니다.");

    }
}


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

class Carrier
{
    public Carrier()
    {
        Console.WriteLine("캐리어가 생성되었습니다.");
        
    }
}

 

 

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

class Lurker
{
    public Lurker()
    {
        Console.WriteLine("러커가 생성되었습니다.");
    }
    //메서드 정의
    //버로우하다
    public Burrow Transform(string name1)
    {
        Console.WriteLine();
        return new Burrow();
    }
}


using System;

namespace HelloWorld
{
    class Program
    {
        
        static void Main(string[] args)
        {
            Hydra hydra; 
            hydra = new Hydra();
            Lurker lurker = hydra.Transform("러커");
            Console.WriteLine(hydra);

            
            Burrow burrow = lurker.Transform("버로우");
            Console.WriteLine(lurker);

        }
    }
}

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

class Hydra
{
    public Hydra() //생성자 메서드
    {
        Console.WriteLine("히드라가 생성되었습니다.");
    }
    //메서드 정의
    //변태하다
    public Lurker Transform(string name)
    {
        Console.WriteLine("히드라가 {0}로 변태합니다.", name);
        return new Lurker();
    }
}


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

class Burrow
{
    public Burrow()
    {
        Console.WriteLine("러커가 버로우 합니다.");
    }
}

마지막에 출력을 하였을 때 영어로 Hydra와 Lurker가 계속 출력이 되서 고민한 후에 console.write()로 바꾸고 나서 출력되지 않는다.  console.write()이 출력한다는 건데 속에 계속 썼더니 영어로 출력이 된 것이었다. 

자꾸 새로운걸 하면 전꺼를 까먹기 때문에 주말에는 시간을 들여 처음부터 모든 문제를 한번씩 다시 해봐야 겠다.

이걸 계속 해도 순서가 아직도 헷갈린다. 주말에 더 연습 해야겠다..!

'c# > 수업 과제' 카테고리의 다른 글

연습과제1번  (0) 2021.08.20
변수와 if ~else 복습  (0) 2021.08.20
산술연산자  (0) 2021.08.19
입력 받기 복습 기본1  (0) 2021.08.18
20210817 과제  (0) 2021.08.17