Reference: https://apcentral.collegeboard.org/media/pdf/ap24-frq-comp-sci-a.pdf
Topics:
Objects - Define
Conditionals
This would be a simple project for the Objects unit.
The following is meant to help get you on your way with testing your solution.
public static void main(String[] args)
{
Scoreboard game = new Scoreboard("Red", "Blue");
System.out.println(game.getScore()); //"0-0-Red"
game.recordPlay(1);
System.out.println(game.getScore()); //"1-0-Red"
game.recordPlay(0);
System.out.println(game.getScore()); //"1-0-Blue"
System.out.println(game.getScore()); //"1-0-Blue" - Nothing Changed
game.recordPlay(3);
System.out.println(game.getScore()); //"1-3-Blue"
game.recordPlay(1);
game.recordPlay(0);
System.out.println(game.getScore()); //"1-4-Red"
game.recordPlay(0);
game.recordPlay(4);
game.recordPlay(0);
System.out.println(game.getScore()); //"1-8-Red"
Scoreboard match = new Scoreboard("Lions", "Tigers");
System.out.println(match.getScore()); //"0-0-Lions"
System.out.println(game.getScore()); //"1-8-Red"
}
All you're doing is creating the Scoreboard object as described above.
Think critically about the Object and what data needs to be saved (hint, there's 5 instance variables in this problem)
Pay attention to what is not being said in the question:
The constructor portion mentions 2 parameters + something representing whose turn it is, but it doesn't mention anything about the 2 scores you need to keep, but they also need to be initialized in the constructor.
This problem does not ask you to do anything beyond
Pay attention to the question wording and don't do anything you don't need to do:
I tell you that every Object should have
Instance Variables
Constructors
Getters
Setters
toString
Optionally - helper functions
In this problem, it specifically states the Object only has 1 constructor + 2 functions. That means:
You don't need getters
You don't need setters
You don't need the toString
For this problem, don't do more work than you need.
The Scoreboard class can be written in under 40 lines of code.