10.02 커피상점
C#/실습 2019. 10. 2. 17:24예제:
커피상점을 만들어 그 커피상점은 커피, 슬리브, 빨대를 만든다.
커피상점이 만든 커피, 슬리브, 빨대를 손님에게 준다.
주는 기능은 커피상점이 갖고있다.
예제:
코드:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
using System;
namespace _10._02_lvl3_CoffeShop
{
class App
{
public App()
{
CoffeeShop coffeeShop = new CoffeeShop("스타벅스");
Coffee coffee1 = coffeeShop.GetCoffee("아메리카노");
sleeve sleeve1 = coffeeShop.Getsleeve("LONDON 로고 슬리프");
straw straw1 = coffeeShop.Getstraw("친환경 종이 빨대");
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
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
|
using System;
namespace _10._02_lvl3_CoffeShop
{
class CoffeeShop
{
public string name;
public CoffeeShop(string name)
{
this.name = name;
Console.WriteLine(this.name + "이(가) 생성되었습니다.");
}
public Coffee GetCoffee(string coffee)
{
Coffee coffee1 = new Coffee(coffee);
return coffee1;
}
public sleeve Getsleeve(string sleeve)
{
sleeve sleeve1 = new sleeve(sleeve);
return sleeve1;
}
public straw Getstraw(string straw)
{
straw straw1 = new straw(straw);
return straw1;
}
public void Give(Coffee coffee, sleeve sleeve, straw straw)
{
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
1
2
3
4
5
6
7
8
9
10
11
12
|
class Coffee
{
public string name;
public Coffee(string name)
{
this.name = name;
Console.WriteLine(this.name + "이(가) 만들어졌습니다.");
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
1
2
3
4
5
6
7
8
9
10
11
|
class sleeve
{
public string name;
public sleeve(string name)
{
this.name = name;
Console.WriteLine(this.name + "이(가) 생성되었습니다.");
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
1
2
3
4
5
6
7
8
9
|
class straw
{
public string name;
public straw(string name)
{
this.name = name;
Console.WriteLine(this.name + "이(가) 생성되었습니다.");
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
'C# > 실습' 카테고리의 다른 글
10.02 자동차 부품설정 (0) | 2019.10.02 |
---|---|
10.02 버거세트 (0) | 2019.10.02 |
10.01 커맨드센터에서 SCV1,2를 만들고 공격하기 (0) | 2019.10.01 |
10.01 여러 class를 이용해 햄버거 세트 만들기 (0) | 2019.10.01 |
워크래프트 캐릭생성하기 (0) | 2019.09.27 |