카테고리 없음

2018.03.23 수업내용 (데이터 맵핑)

일등하이 2018. 5. 15. 21:23
반응형
03.23 과제 발표 

데이터 맵핑에 대한 예제 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApp9
{
    public class Animal
    {
        public AnimalData data;
 
        public Animal(AnimalData data)
        {
            this.data = data;
        }
 
        public void AnimalCrying()
        {
            Console.WriteLine(this.data.name + "의 울음소리: " + this.data.strCrySound);
        }
    }
}
 
cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApp9
{
    public class AnimalData
    {
        public string name;
        public string strCrySound;
 
        public AnimalData(string name, string strCrySound)
        {
            this.name = name;
            this.strCrySound = strCrySound;
        }
    }
}
 
cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApp9
{
    public class App
    {
        public void Run()
        {
            Animal dog = new Animal(new AnimalData("강아지""멍멍"));
            Animal cat = new Animal(new AnimalData("고양이""야옹"));
 
            dog.AnimalCrying();
            cat.AnimalCrying();
 
        }
    }
}
 
cs


반응형