Skip to content

LuDochka2/color

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

colorclass GreenApple:

def __init__(self, variety, ripeness='unripe'):
    self.variety = variety
    self.ripeness = ripeness
    self.is_picked = False

def ripen(self):
    if not self.is_picked:
        if self.ripeness == 'unripe':
            print(f"The {self.variety} apple is ripening.")
            self.ripeness = 'ripe'
        elif self.ripeness == 'ripe':
            print(f"The {self.variety} apple is already ripe.")
    else:
        print(f"The {self.variety} apple has been picked and cannot ripen further.")

def pick(self):
    if not self.is_picked:
        print(f"Picking the {self.variety} apple.")
        self.is_picked = True
    else:
        print(f"The {self.variety} apple has already been picked.")

def describe(self):
    print(f"This is a {self.ripeness} {self.variety} apple.")

Main program

if name == "main": # Create a green apple instance apple = GreenApple(variety="Granny Smith")

# Describe the apple
apple.describe()

# Ripen the apple
apple.ripen()

# Pick the apple
apple.pick()

# Try to ripen the apple after picking
apple.ripen()

# Describe the apple again
apple.describe()

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published