12일차 클래스(3)
Console Programming/C# Console 2019. 10. 8. 08:48
|
|
Program.cs
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GetSetValueMeal
{
class Program
{
static void Main(string[] args)
{
new App();
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
|
|
App.cs | |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GetSetValueMeal
{
public class App
{
public App()
{
var valueMeal1 = new ValueMeal("몬스터X 세트");
var burger1 = new Burger("몬스터X 버거");
var drink1 = new Drink("콜라(L)");
var sideDish1 = new SideDish("프렌치프라이(L)");
Console.WriteLine($"{valueMeal1.GetValueMealName()}을 만들었습니다.");
valueMeal1.SetBurger(burger1);
var burgerMonsterX = valueMeal1.GetBurger();
Console.WriteLine($"{burgerMonsterX.GetBurgerName()}");
valueMeal1.SetDrink(drink1);
var drinkMonsterX = valueMeal1.GetDrink();
Console.WriteLine($"{drinkMonsterX.GetDrinkName()}");
valueMeal1.SetSideDish(sideDish1);
var sideDishMonsterX = valueMeal1.GetSideDish();
Console.WriteLine($"{sideDishMonsterX.GetSideDishName()}");
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
|
|
ValueMeal.cs | |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GetSetValueMeal
{
public class ValueMeal
{
//data
//name
//burger
//drink
//sideDish
string name;
Burger burger;
Drink drink;
SideDish sideDish;
public ValueMeal(string name)
{
this.name = name;
}
//function
//GetValueMealName
//SetBurger
//GetBurger
//SetDrink
//GetDrink
//SetSideDish
//GetSideDish
public string GetValueMealName()
{
return this.name;
}
public void SetBurger(Burger burger)
{
this.burger = burger;
}
public Burger GetBurger()
{
return this.burger;
}
public void SetDrink(Drink drink)
{
this.drink = drink;
}
public Drink GetDrink()
{
return this.drink;
}
public void SetSideDish(SideDish sideDish)
{
this.sideDish = sideDish;
}
public SideDish GetSideDish()
{
return this.sideDish;
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
|
|
Burger.cs | |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GetSetValueMeal
{
public class Burger
{
//data
//name
string name;
public Burger(string name)
{
this.name = name;
}
//function
public string GetBurgerName()
{
return this.name;
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
|
|
Drink.cs | |
|
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;
namespace GetSetValueMeal
{
public class Drink
{
//data
//name
string name;
public Drink(string name)
{
this.name = name;
}
public string GetDrinkName()
{
return this.name;
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
|
|
SideDish.cs | |
|
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;
namespace GetSetValueMeal
{
public class SideDish
{
//data
//name
string name;
public SideDish(string name)
{
this.name = name;
}
public string GetSideDishName()
{
return this.name;
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|

'Console Programming > C# Console' 카테고리의 다른 글
| 14일차 배열의 선언 및 초기화. cost와 name 멤버변수를 가진 클래스 product (0) | 2019.10.10 |
|---|---|
| 12일차 클래스(4) (0) | 2019.10.08 |
| 12일차 클래스(2) (0) | 2019.10.08 |
| 12일차 클래스 2차원 위치정보 (0) | 2019.10.08 |
| 백준 2675 문자열 반복 (0) | 2019.10.08 |

