ch3p-Party (Main class)

AppParty     readme Food







Party.cs


using System.Collections.Generic; // for List
using party.house; // for House
using party.house.rooms; // for Room, Kitchen, Diner, BedRoom
using party.house.rooms.furniture; // for Bed, BedType, Table,
// DiningTable, KitchenTable, Chair, ArmChair, DiningChair, KitchenChair
using party.house.occupants; // for Robot, Host, Guest
using party.foods; // for Food, Drink, Cake, Soda

namespace party
{
public class Party
{
static void StartParty()
{
System.Console.WriteLine("Start the party!");
}

public static void Main()
{
Robot r = new Robot("Robbie");
House house = new House("228 Maple Rd.", r);

Table kt = new KitchenTable("Kitchen table");
Kitchen kitchen = new Kitchen("Kitchen", kt);
Chair kc1 = new KitchenChair("kc1");
Chair kc2 = new DiningChair("kc2");
kitchen.AddChair(kc1);
kitchen.AddChair(kc2);
// System.Console.WriteLine(kitchen); // kitchen.ToString()
house.AddRoom(kitchen);

Diner diner = new Diner("Dining room");
Chair ac = new ArmChair("armchair");
Chair dc1 = new DiningChair("dc1");
Chair dc2 = new DiningChair("dc2");
diner.AddChair(ac);
diner.AddChair(dc1);
diner.AddChair(dc2);
// System.Console.WriteLine(diner); // diner.ToString()
house.AddRoom(diner);

Bed bed = new Bed(BedType.Double);
BedRoom bedroom = new BedRoom("Bedroom", bed);
bedroom.SetChair(new ArmChair("armchair"));
// System.Console.WriteLine(bedroom); // bedroom.ToString()
house.AddRoom(bedroom);

Host h1 = new Host("John");
Host h2 = new Host("Patricia");
house.AddHost(h1);
house.AddHost(h2);

Guest g1 = new Guest("Martin");
Guest g2 = new Guest("Linda");
r.AddGuest(g1);
r.AddGuest(g2);

System.Console.WriteLine(house.ToString());
bed.MakeBed(r);

System.Console.WriteLine(h1 + " and " + h2 + " decide to have a party!");
System.Console.WriteLine(r.Invitations());

DiningTable dt = (DiningTable)(diner.GetTable());
Drink coke = new Soda("Coca Cola");
Food cake = new Cake("Fruit cake");
dt.AddFood(cake);
dt.AddDrink(coke);

StartParty();
System.Console.WriteLine(dt);

System.Console.WriteLine(coke);
System.Console.WriteLine(cake);
((Cake)cake).Celebrate(); // Food cake downcast to Cake

kitchen.CleanKitchen(r);
diner.CleanDiner(r);
r.ClearGuests();
}
}
}
/*
// Open terminal in the folder containing folder party:
mcs -recurse:party/*.cs -main:party.Party -out:Party.exe
// -recurse:party/*.cs search recursively in folder party for source files
// main: class containing the Main() method
// -out:Party.exe output in the current folder

mono Party.exe
House on 228 Maple Rd. holds robot Robbie, 2 hosts: John, Patricia,
and 3 rooms: Kitchen, Dining room, Bedroom,
Robbie makes the bed
John and Patricia decide to have a party!
Robbie invited: Martin, Linda,
Start the party!
Dining table is luxurious; foods: Fruit cake, drinks: Coca Cola,
Coca Cola is refreshing
Fruit cake is delicious
Match is practical
Lighting a match
Candle is romantic
Lighting a candle
Robbie cleans the kitchen
Robbie cleans the diner
Robbie says Good bye to all the guests
*/









AppParty     readme BACK_TO_TOP Food



Comments

Popular posts from this blog

Contents