📅  最后修改于: 2023-12-03 15:27:53.424000             🧑  作者: Mango
"Bagu Kangaroo Court" is a fun programming challenge where you have to write a program that can put animals on trial! This online platform provides a digital environment in which you can practice and enhance your programming skills!
The "court" is a virtual place where the animals come to voice their grievances. Your program will act as the judge and will decide who is guilty and who is innocent based on the evidence presented.
Each animal is represented by a set of attributes such as "name," "color," and "weight." Your task is to write code that can compare these attributes to decide which animal is guilty.
The trial is simple: a single animal initiates the case and the other animals participate as witnesses. The judge (your program) will ask each animal about their observations and then make a verdict.
Here's an example of what a "Bagu Kangaroo Court" program might look like:
class Animal:
def __init__(self, name, color, weight):
self.name = name
self.color = color
self.weight = weight
class Judge:
def __init__(self):
self.criteria = {"name": "", "color": "", "weight": ""}
def ask_questions(self, animal):
# Ask the animal to provide information about the case.
print(f"What did you observe about {animal.name}?")
def compare_attributes(self, animal):
# Compare the animal's attributes to the criteria set by the judge.
if animal.name == self.criteria["name"] and \
animal.color == self.criteria["color"] and \
animal.weight == self.criteria["weight"]:
return True
else:
return False
def set_criteria(self, name="", color="", weight=""):
# Set the criteria for the trial.
self.criteria["name"] = name
self.criteria["color"] = color
self.criteria["weight"] = weight
# Create some animals.
kangaroo = Animal("Joey", "brown", 25)
giraffe = Animal("Gerry", "yellow", 500)
elephant = Animal("Elle", "gray", 800)
# Set the judge's criteria.
judge = Judge()
judge.set_criteria(name="Joey", color="brown", weight=25)
# Have the judge ask questions and compare the attributes.
judge.ask_questions(kangaroo)
if judge.compare_attributes(kangaroo):
print("Guilty!")
else:
print("Not guilty.")
"Bagu Kangaroo Court" is a fun way to develop your programming skills and learn about conditional statements, data structures, and algorithms. Try it out today!