Java Bootcamp – Workbooks and Challenges
)}

Quidditch – Part 1

The Quidditch application will cover:

  • Stream Pipelines
  • HashMap (new)
  • hashCode() (new)
  • static variables
  • static final constants
  • static methods

Setup

8c6dce82-e2c7-4814-9652-e3a8bda38e02

requirements.txt


Objects: Team and Game.

  • Team:
    • fields: house, keeper, seeker, and chasers.
  • Game:
    • fields: scoreBoard.
    • actions: see test cases.
    • constants: QUAFFLE_POINTS and SNITCH_POINTS.

Task 1


Add the necessary fields to the Team class. Protect each field using the private keyword.

Task 2


Add a constructor. The constructor parameters are String house, String keeper, String seeker, String[] chasers.

Task 3


Add a copy constructor.

Task 4


Add getters and setters.

Task 5


Add a toString method that returns the following:

   return "House: " + this.house + "\n" +
          "Keeper: " + this.keeper + "\n" +         
          "Seeker: "  + this.seeker + "\n" +         
          "Chasers: " + Arrays.toString(this.chasers) + "\n"; 

Task 6


Test your code by creating two objects of the Team class:

     new Team("GRYFFINDOR", "Oliver", "Harry", 
       new String[] {"Angelina", "Ginny", "Katie"});
 
     new Team("SLYTHERIN", "Vincent",  "Draco", 
       new String[] {"Bridget", "Harper", "Malcolm"});

Finally, print each object:

>>: House: GRYFFINDOR
>>: Keeper: Oliver
>>: Seeker: Harry
>>: Chasers: [Angelina, Ginny, Katie]

>>: House: SLYTHERIN
>>: Keeper: Vincent
>>: Seeker: Draco
>>: Chasers: [Bridget, Harper, Malcolm]

Your terminal should point to the folder quidditch-game. 6f3e8e75-c66a-4bc8-94d1-2ba41902a5b6

But, Main.java is inside src/main. I recommend just using the run button. Keep pressing "Proceed" until the errors go away.

Screen Shot 2022-02-15 at 6.52.39 PM.png

Alternatively, if you feel like writing out the commands:

  • Mac users: write javac src/main/Main.java.

  • Windows users: write javac src\main\Main.java.

Mac uses / forward-slash for paths. Windows uses backslash \.

Good Luck!

Feedback Summary
4.8
39 students
5

92%
4

3%
3

0%
2

0%
1

5%
Written Reviews
There are no written reviews yet.