728x90
SMALL

// RPGの冒者クラスを作ろう

 

using System;

 

public class Practice

{

    public static void Main()

    {

        var adventurer = new Adventurer("");

        var wizard = new Adventurer("ウィザ");

        var crusader = new Adventurer("クルセイダ");

        var priest = new Adventurer("プリスト");

 

        Adventurer[] party = {adventurer, wizard, crusader, priest};

 

        foreach (Adventurer player in party)

        {

            player.Attack();

        }

    }

}

 

///

 

모험자, 위자드, 크루세이더, 프리스트 출력

 

///

// Adventurerクラスを定義する

public class Adventurer

{

    private string name;

    public Adventurer(string name)

    {

        this.name = name;

    }

 

    public void Attack()

    {

        Console.WriteLine(name + "は魔王を攻した");

       

    }

}

/////////////

////

728x90

설정

트랙백

댓글