Created
October 2, 2010 23:38
-
-
Save zonoise/608107 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
//「カレー」を作るのC言語での表現です。(ジョークアプリ) | |
//コンパイルして、実行してもなにもおきません。 | |
// | |
//レシピはハウス食品のサイトを参考にしました。 | |
//http://housefoods.jp/products/catalog/pkgview.php?cd=82995&ct=1 | |
// | |
//下記の機能は未実装となっています。 | |
//アクを取る | |
//n分間煮込む | |
//沸騰検知 | |
//あとかたずけ(free) | |
// | |
// Structs and Enum | |
// | |
//食品 | |
typedef struct tagFood{ | |
struct tagFood *next; | |
char *name; | |
char *style; | |
}Food; | |
//火加減 | |
enum Heat { | |
LOW, | |
MEDIUM, | |
HIGH, | |
STOP, | |
}; | |
//厚手の鍋 | |
typedef struct tagHeavyPan{ | |
enum Heat heat; | |
int status; | |
Food *food; | |
}HeavyPan; | |
// | |
// Functions | |
// | |
//材料を用意する | |
Food* alloc_food(const char* food_name){ | |
Food *f=NULL; | |
f=(Food *)malloc(sizeof(Food)); | |
f->name=(char *)malloc(sizeof(char)*strlen(food_name)+1); | |
strcpy(f->name,food_name); | |
return f; | |
} | |
//厚手の鍋を用意する | |
HeavyPan* alloc_pan(){ | |
HeavyPan *pan=(HeavyPan *)malloc(sizeof(HeavyPan)); | |
memset((void *)pan,0x00,sizeof(HeavyPan)); | |
return pan; | |
} | |
//材料の加工 | |
void set_food_style(Food *food,const char *food_style){ | |
food->style=(char *)malloc(sizeof(char)*strlen(food_style)); | |
strcpy(food->style,food_style); | |
} | |
//シェフ専用 | |
void print_food(Food *food){ | |
printf("name:%s\n",food->name); | |
printf("style:%s\n",food->style); | |
} | |
//鍋に材料を投入する | |
void add_food(HeavyPan* pan,Food *food){ | |
//first | |
if(NULL == pan->food){ | |
pan->food=food; | |
return; | |
} | |
Food *f=pan->food; | |
//get_tail | |
while(f->next){ | |
f=f->next; | |
} | |
//add tail | |
f->next=food; | |
} | |
//シェフ専用 | |
void print_food_list(Food *food_list){ | |
Food *f=food_list; | |
while(1){ | |
print_food(f); | |
if(NULL==f->next){ | |
break; | |
} | |
f=f->next; | |
} | |
} | |
//カレーを作る。 | |
void make_carry(){ | |
//食材を用意します。 | |
Food *meat = alloc_food("meat"); | |
Food *onion = alloc_food("onion"); | |
Food *potato = alloc_food("potato"); | |
Food *carrot = alloc_food("carrot"); | |
Food *oil = alloc_food("oil"); | |
Food *water = alloc_food("water"); | |
Food *roux = alloc_food("vermontcarry"); | |
//厚手の鍋を用意します。 | |
HeavyPan *pan=alloc_pan(); | |
//材料を加工します。 | |
set_food_style(meat,"hitokuchi-dai"); | |
set_food_style(carrot,"hitokuchi-dai"); | |
set_food_style(onion,"hitokuchi-dai"); | |
set_food_style(potato,"hitokuchi dai"); | |
//厚手の鍋にサラダ油を熱します。 | |
pan->heat=LOW; | |
add_food(pan,oil); | |
//一口大に切った肉、野菜をよくいためます。 | |
add_food(pan,meat); | |
add_food(pan,onion); | |
add_food(pan,potato); | |
add_food(pan,carrot); | |
//水を加え、沸騰したら | |
add_food(pan,water); | |
pan->heat=HIGH; | |
//アクを取り、 | |
//(未実装) | |
//材料がやわらかくなるまで弱火中火で15分間煮込みます。 | |
pan->heat=MEDIUM; | |
//いったん火を止め、ルウを割入れて、溶かします。 | |
pan->heat=STOP; | |
set_food_style(roux,"waru"); | |
add_food(pan,roux); | |
//再び、弱火でとろみがつくまで、約10分間煮込みます。 | |
pan->heat=LOW; | |
} | |
int main(int argc, char *argv[]){ | |
make_carry(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment