using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Study_011
{
class APP3
{
public APP3()
{
//캐릭터 생성
Character Sylvanas = new Character("실바나스");
//레시피 생성
string[] arrFoodIngredientNames = new string[5];
arrFoodIngredientNames[0] = "타조 고기";
arrFoodIngredientNames[1] = "윤기나는 빨간 사과";
//Recipe recipe = new Recipe("타조스튜", "타조 고기", "윤기나는 빨간 사과"); //조리법 이름
Recipe recipe = new Recipe("타조스튜", arrFoodIngredientNames);
//레시피 이름을 출력
Console.WriteLine(recipe.GetName()); // 조리법 : 타조 스튜 로 노출되게
//캐릭터가 레시피를 획득한다.
Sylvanas.GetRecipe(recipe);
//레시피 생성
arrFoodIngredientNames = new string[2];
arrFoodIngredientNames[0] = "거대한 알";
arrFoodIngredientNames[1] = "독특한 양념";
recipe = new Recipe("괴물 오믈렛", arrFoodIngredientNames);
// 캐릭터가 레시피 획득
Sylvanas.GetRecipe(recipe);
Sylvanas.UseRecipe("괴물 오믈렛");
arrFoodIngredientNames = new string[2];
arrFoodIngredientNames[0] = "토끼 엉겅퀴풀";
arrFoodIngredientNames[1] = "맑은 샘물";
recipe = new Recipe("엉겅퀴 차", arrFoodIngredientNames);
Sylvanas.GetRecipe(recipe);
Sylvanas.ViewHandRecipe();
Sylvanas.skillRecipe();
//선택한 레시피 정보 출력
Sylvanas.PrintRecipeInfo("괴물 오믈렛");
Console.WriteLine("--------------------------------");
// 괴물 오물렛 ( 거대한 알 , 독특한 양념 )
//요리를 만든다 // 우선 재료 창조
Sylvanas.GetFoodIngredient (new FoodIngredient("거대한 알", 1));
Sylvanas.GetFoodIngredient(new FoodIngredient("독특한 양념", 1));
}
}
}
================================================================================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Study_011
{
class Character
{
public string name;
public Recipe[] arrRecipe; // 소지중인 레시피들
public Recipe[] arrCookRecipe; // 조리가능한 레시피들
public int recipeIndex; //레시피 배열의 인덱스
public int cookrecipeIndex = 0;
public FoodIngredient[] arrFoodIngredients; // 소지하려고하는 재료들 [배열 선언]
public int foodingredientIndex;
public Character(string name)
{
this.name = name;
this.arrRecipe = new Recipe[10]; // 레시피 배열 객체 생성
this.arrCookRecipe = new Recipe[10];
this.arrFoodIngredients = new FoodIngredient[10];
Console.WriteLine(name + "가 생성됨");
}
public Recipe GetRecipe(Recipe recipe)
{
this.arrRecipe[recipeIndex++] = recipe;
Console.WriteLine("{0}을 습득", recipe.GetName());
// 제조법 : 타조 스튜를 획득 했습니다.
return recipe;
}
public void UseRecipe(string recipeName)
{
{
Recipe recipe = this.arrRecipe[i];
if (recipe != null)
{
{
Console.WriteLine("{0}을 습득합니다.", recipe.GetName());
arrCookRecipe[cookrecipeIndex] = arrRecipe[i];
arrRecipe[i] = null;
Console.WriteLine("조리배열 : {0} / {1} ", cookrecipeIndex, arrCookRecipe[cookrecipeIndex].name);
cookrecipeIndex++;
}
else
{
}
}
}
//앞쪽으로 당기기
}
public void ViewHandRecipe()
{
Console.WriteLine("****소지중인레시피****");
{
Recipe recipe = this.arrRecipe[i];
if (recipe == null)
Console.WriteLine("[ ]");
else
}
}
public void skillRecipe()
{
Console.WriteLine("****할수있는레시피****");
{
Recipe recipe = this.arrCookRecipe[i];
if (recipe == null)
Console.WriteLine("[ ]");
else
}
Console.WriteLine("********************");
}
public void PrintRecipeInfo(string recipeName)
{
//현재배운 레시피 배열의 요소중 name 멤버 변수의 값이
//recipeName 와 같은 레시피 객체를 찾아낸다.
Recipe foundRecipe = null;
foreach (Recipe recipe in this.arrCookRecipe)
{
if (recipe != null)
{
{
foundRecipe = recipe;
break;
}
}
}
Console.WriteLine("{0}", foundRecipe.GetName());
foreach (string ingredient in foundRecipe.arrFoodIngredientNames)
{
Console.WriteLine("재료 : {0}", ingredient);
}
}
// 우선 캐릭터는 조리법만 주웠다
// 재료를 습득해야하고, 그 필요재료가 있는지 확인해야한다
// >> 음식 재료 배열 생성 뒤 거기에 추가하고, 추후 레시피 돌려서 있는지 하면 될거 같음
public FoodIngredient GetFoodIngredient(FoodIngredient FoodIngredients)
{
this.arrFoodIngredients[foodingredientIndex] = FoodIngredients;
foodingredientIndex++;
return FoodIngredients;
}
//public void check()
//{
// foreach (FoodIngredient name in arrFoodIngredients)
// {
// Console.WriteLine(name);
// }
//}
public void Cook(string cookName)
{
int cookidx = 0;
foreach (Recipe recipe in arrCookRecipe)
{
if (recipe != null)
{
if (this.arrCookRecipe[cookidx].name == cookName)
{
Console.WriteLine("일치하는 레시피 확인 --->> {0}", arrCookRecipe[cookidx].name);
//재료가 있는지 확인
}
}
cookidx++;
}
}
}
}
===============================================================================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Study_011
{
class Recipe
{
public string name; // 레시피 이름 (만들어질 음식이름 )
public string[] arrFoodIngredientNames; //만들어질 음식에 필요한 재료이름들
//생성자
public Recipe(string name, string[] arrFoodIngredientNames)
{
this.name = name;
this.arrFoodIngredientNames = arrFoodIngredientNames;
}
public string GetName()
{
return "조리법 : " + this.name; //언제나 리턴은 ""값"" 이 와야한다.
}
}
}
==============================================================================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Study_011
{
class Food
{
public string name;
public Food(string name)
{
this.name = name;
}
}
}
===========================================================================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Study_011
{
class FoodIngredient
{
public string name;
public int amount;
public FoodIngredient(string name, int amount)
{
this.name = name;
this.amount = amount;
}
}
}