示例#1
0
void LField::Sync() {
	if (((GetCond() > 3) && (GetCond() < 7)) ||
		((GetCond() > 11) && (GetCond() < 15)))	{
		GetPlant()->kurangiUmur(1);
		if (IsSiram()) {
			GetPlant()->tambahHappyMeter(1);
		}
	}
	Siram = 0;	
}
示例#2
0
/// Print power plant market info
void CardStack::PrintInfo() {
    std::cout << std::endl;
    std::cout << "Current plants: " << std::endl;
    for (int i = 0; i < futureMarketIndex; i++)
        std::cout << "[" << i << "] " << *GetPlant(i) << std::endl;

    std::cout << std::endl;

    std::cout << "Future plants: " << std::endl;
    for (int i = futureMarketIndex; i < visibleCards; i++)
        std::cout << "[" << i << "] " << *GetPlant(i) << std::endl;
    std::cout << std:: endl;
}
示例#3
0
Fruit* Orchard::GetBestFruit(int i, int j, int *fruitID) {
	//goes to DS and gets Fruit with lowest ripe rating, min is 1.
	if (!legalInput(i, j)) {
		throw InvalidInput();
	}
	Plant* plant = GetPlant(i, j);
	return plant->GetBestFruit();

}
示例#4
0
void Orchard::RemoveFruit(int fruitID) {
	if (!legalFruitID(fruitID)) {
		throw InvalidInput();
	}
	//we need to remove from both DS's
	try {
		Fruit* fruit = GetFruit(fruitID);
		Plant* plant = GetPlant(fruit->getLocation().msi,
				fruit->getLocation().lsi);

		plant->RemoveFruit(fruitID); // deleting the fruit
		Fruits.Remove(fruitID);
		//delete fruit;
	} catch (KeyDoesNotExist& e) {
		throw Failure();
	}
}
示例#5
0
void Orchard::AddFruit(int i, int j, Fruit* fruit) {
	if (!fruit) {
		throw InvalidInput();
	}
	if (!legalInput(i, j)) {
		throw InvalidInput();
	}
	//we need to add to both DS's
	if (!DoesExist(i, j))
		throw PlantDoesNotExist();
	if (DoesExist(fruit->getID()))
		throw FruitAlreadyExist();

	fruit->setLocation(PairID(i, j));
	Plant* temp = GetPlant(i, j);
	temp->AddFruit(fruit);
	Fruits.Insert(fruit->getID(), fruit);
}
示例#6
0
void Orchard::RateFruit(int id, int ripeness) {
	if (id < 0 || ripeness <= 0) {
		throw InvalidInput();
	}
	//we need to add to both DS's
	try {
		Fruit* fruit = GetFruit(id);
		Plant* plant = GetPlant(fruit->getLocation().msi,
				fruit->getLocation().lsi);
		Fruit* copy = new Fruit(*fruit);
		copy->setRipeRate(ripeness);

		plant->RemoveFruit(id);
		plant->AddFruit(copy);

		Fruits.Remove(id);
		Fruits.Insert(id, copy);

	} catch (KeyDoesNotExist& e) {
		throw Failure();
	}
}
示例#7
0
// TODO: delete
void* Orchard::GetAllFruitsByRate(int i, int j, int **fruits,
		int *numOfFruits) {
	return GetPlant(i, j)->GetAllFruitsByRate();
}