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 0
  • void addPoints(int points): Adds points. If a negative value is passed, prints Error: Points cannot be negative to stdout and returns without modifying points
  • boolean usePoints(int points): Deducts points. Returns true and subtracts if balance is sufficient; returns false if insufficient
  • int getPoints(): Returns current point balance
  • String 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