Notice
Recent Posts
Recent Comments
Link
스토리지
과제 7 본문
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);
}
}
}
}
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);
}
}
}
}
Comments