11일차 클래스(2)
Console Programming/C# Console 2019. 10. 4. 14:17자판기
------------------
이름: 음료자판기
------------------
음료를 만든다
음료
------------------
이름: 칠성사이다
이름: 비락식혜
이름: 코카콜라
요구사항
------------------
생성자 메서드 (매개변수)
|
Drink.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;
namespace Syntax29
{
public class Drink
{
//데이터
//이름
public string name;
public Drink(string name)
{
this.name = name;
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
|
VendingMachine.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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Syntax29
{
public class VendingMachine
{
//데이터
//이름
public string name;
public VendingMachine(string name)
{
this.name = name;
}
public Drink TakeDrnik(string name)
{
Drink drink = new Drink(name);
return drink;
}
}
}
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Syntax29
{
public class App
{
public App()
{
VendingMachine vendingmachin1 = new VendingMachine("음료자판기");
Drink drink1 = new Drink("칠성사이다");
Drink drink2 = new Drink("비락식혜");
Drink drink3 = new Drink("코카콜라");
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
'Console Programming > C# Console' 카테고리의 다른 글
11일차 클래스(4) (0) | 2019.10.04 |
---|---|
11일차 클래스(3) (0) | 2019.10.04 |
11일차 클래스 피자상점 (0) | 2019.10.04 |
10일차 클래스(2) 버거상점, 세트메뉴 (0) | 2019.10.04 |
10일차 클래스 커맨트센터, 유닛(공격,피격) (0) | 2019.10.04 |