스토리지

과제 7 본문

Unity/수업과제

과제 7

ljw4104 2021. 3. 17. 08:01

1. 오락실 리듬게임 EZ2AC의 곡의 데이터들을 담아놓은 Dictionary

 

 

using System;

namespace Study07
{
    public class Song
    {
        private int ID;
        private int bpm;
        private string songName;
        private string composer;
        public Song()
        {

        }

        public Song(int ID, int bpm, string songName, string composer)
        {
            this.ID = ID;
            this.bpm = bpm;
            this.songName = songName;
            this.composer = composer;
        }

        public override string ToString()
        {
            string result = String.Format("{0}, {1}, {2}, {3}", this.ID, this.bpm, this.songName, this.composer);
            return result;
        }
    }
}
using System;
using System.Collections.Generic;

namespace Study07
{
    public class App
    {
        public App()
        {
            Dictionary<int, Song> dicSong = new Dictionary<int, Song>();

            Song s1 = new Song(1, 130, "Revival On", "Warak");
            Song s2 = new Song(14, 200, "Yog-Sothoth", "nato");
            Song s3 = new Song(5, 222, "GEHENNA", "Mori†");

            dicSong.Add(1,s1);
            dicSong.Add(14, s2);
            dicSong.Add(5, s3);

            foreach(var i in dicSong)
            {
                Console.WriteLine(i.Value);
            }
        }
    }
}

ID, BPM, 타이틀, 작곡가 순으로 표기된다

 

 

2. 메이플스토리의 한 지역 아케인리버의 마을들을 List에 담음

 

 

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

namespace Study07
{
    public class Map
    {
        private int ID;
        private int levelLimit;
        private string townName;
        private Map subTown;
        public Map()
        {

        }

        public Map(int ID, int levelLimit, string townName, Map subTown)
        {
            this.ID = ID;
            this.levelLimit = levelLimit;
            this.townName = townName;
            this.subTown = subTown;
        }

        public override string ToString()
        {
            string temp = String.Empty;
            if(this.subTown != null)
            {
                temp = String.Format("{0}, {1} {2}", townName, levelLimit, subTown.townName);
            }
            else
            {
                temp = String.Format("{0}, {1} {2}", townName, levelLimit, null);
            }
            return temp;
        }
    }
}
using System;
using System.Collections.Generic;

namespace Study07
{
    public class App
    {
        public App()
        {
            List<Map> arcaneRiver = new List<Map>();

            arcaneRiver.Add(new Map(1, 200, "소멸의 여로", new Map(8, 205, "리버스시티", null)));
            arcaneRiver.Add(new Map(2, 210, "츄츄 아일랜드", new Map(9, 215, "얌얌 아일랜드", null)));
            arcaneRiver.Add(new Map(3, 220, "레헬른", null));
            arcaneRiver.Add(new Map(4, 225, "아르카나", null));
            arcaneRiver.Add(new Map(5, 230, "모라스", null));
            arcaneRiver.Add(new Map(6, 235, "에스페라", new Map(7,245,"테네브리스",null)));

            foreach(var i in arcaneRiver)
            {
                Console.WriteLine(i);
            }
        }
    }
}

마을이름, 레벨제한, 마을에서 연결된 다른 마을이 있는지, 있으면 표기, 없으면 NULL

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

과제 - 2048 게임  (0) 2021.03.20
과제 8  (0) 2021.03.17
과제 6  (0) 2021.03.16
과제 5  (0) 2021.03.14
과제 4  (0) 2021.03.12
Comments