OOP HomeWork

This commit is contained in:
e2hang
2025-08-11 00:01:30 +08:00
commit e8a5ca2363
119 changed files with 3187 additions and 0 deletions

60
oop_hw6/hw4/fruit.cpp Normal file
View File

@@ -0,0 +1,60 @@
#include "fruit.h"
Fruit::Fruit()
{
weight = 0;
loss = 0;
}
Fruit::Fruit(int w, int l)
{
weight = w;
loss = l;
}
int& Fruit::checkWeight()
{
return weight;
}
int Fruit::checkLoss()
{
return loss;
}
void Fruit::upDate()
{
this->DatePassed++;
}
void Fruit::Dryed()
{
this->Dry = true;
}
bool Fruit::isDryed()
{
return Dry;
}
void Apple::losewater()
{
if (this->checkWeight() > 30) {
this->checkWeight() -= 4;
}
else
{
this->Dryed();
}
}
void Orange::losewater()
{
if (this->checkWeight() > 18) {
this->checkWeight() -= 3;
}
else
{
this->Dryed();
}
}