008-002-006
Multiple Method Combination: Execute Methods with Arguments and Return Values in Point Card Class
Medium
Problem Description
Implement a Solution class that manages a point card.
Methods to Implement
Solution(String ownerName): Constructor. Receives owner name and initializes points to 0void addPoints(int points): Adds points. If a negative value is passed, printsError: Points cannot be negativeto stdout and returns without modifying pointsboolean usePoints(int points): Deducts points. Returnstrueand subtracts if balance is sufficient; returnsfalseif insufficientint getPoints(): Returns current point balanceString getRank(): Returns rank string based on points (≥100 →"Gold", ≥50 →"Silver", otherwise →"Bronze")String getOwnerName(): Returns the owner name
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up