Skip to content

Advanced-Programming-NIT-4022/Quidditch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Quidditch

In this assignment, we will delve into Object-Oriented Programming (OOP) with a simple but appealing mini project. This mini project would be very enjoyable for Harry Potter fans, but if you haven't watched the film, don't worry; you don't need any pre-knowledge about this film to do this assignment. You can also use this link to read about Quidditch rules.

What Should I Do

Your assignment is a bit different from the real game. You won't need to implement any GUI or complex logic; the whole logic will be handled by chance. Don't worry!

We have two teams. Each team has a keeper, a seeker, 3 chasers, and 2 beaters. You can read about each role's responsibilities in the above link, so let's talk about implementing the project. Each of these roles has a name, number, and each one has a method called isSuccessful. The chance of success varies for each one. Let's start with the keeper.

Keeper

The keeper has a 70% chance to save a hanging goal.

Seeker

The seeker has a 5% chance to find the golden snitch.

Chaser

The chaser has a 30% chance to score a goal.

Beater

The beater has a 40% chance to stop chasers.

How to Implement

Classes

  • Create a class for each role (Keeper, Seeker, etc.).
  • Create a class called Player and make all roles inherit this class.
  • Create an interface called Success and put the method isSuccessful inside it. Don't forget to implement this interface with all of your roles. What's next?

Team

  • Create a class for Team. This class contains players of your team (1 Keeper, 1 Seeker, 3 Chasers, and 2 Beaters) and the number of goals, which is zero at the beginning of the game.
  • It has a method called setGoal, and after calling it, the number of goals increases by one. However, this method is private.
  • Also, we have another method called play. After calling this method, the team will start playing the game, and if the conditions are met, then the setGoal method will be called.
Setting Goal Conditions:

When the keeper of the team is successful in saving the goal, at least one beater is successful, and at least two chasers are successful in the match, then the team will score a goal.

Winning Conditions:

When a seeker of a team finds the golden snitch, the team will get 150 scores and will win the match. Otherwise, the team with the most goals will win the match.

Match

After you've created the Team class, it's time for the Match class. In this class, you will need to create two teams initially. Then, you create a method called start. This method will start the game.

Game Starting:

The game consists of 100 rounds. In each round, both teams will play, and after finishing the game, the scores of both teams will be shown, and also the winning team will be shown as the winner. Don't forget that the game can also end in a draw.

MyApp

The final class you need is the MyApp class. In this class, you will create a match and start that match in your main method. Run the program and enjoy it!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published