Class Jar

java.lang.Object
angry3vilbot.bankingapp.Jar

public class Jar extends Object
Jar class represents a savings jar with an ID, title, goal amount, and current balance. It provides constructors to initialize the jar with or without a goal amount. It also provides getter methods to access the jar's properties.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private double
    Current balance of the jar
    private double
    Goal amount for the jar (optional)
    private int
    ID of the jar
    private String
    Title of the jar
  • Constructor Summary

    Constructors
    Constructor
    Description
    Jar(int id, String title, double balance)
    Constructs a Jar object with the specified ID, title, and balance but without a goal.
    Jar(int id, String title, double goal, double balance)
    Constructs a Jar object with the specified ID, title, goal, and balance.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Gets the current balance of the jar.
    double
    Gets the goal amount of the jar.
    int
    Gets the ID of the jar.
    Gets the title of the jar.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • id

      private int id
      ID of the jar
    • title

      private String title
      Title of the jar
    • goal

      private double goal
      Goal amount for the jar (optional)
    • balance

      private double balance
      Current balance of the jar
  • Constructor Details

    • Jar

      public Jar(int id, String title, double goal, double balance)
      Constructs a Jar object with the specified ID, title, goal, and balance.
      Parameters:
      id - the ID of the jar
      title - the title of the jar
      goal - the goal amount for the jar
      balance - the current balance of the jar
    • Jar

      public Jar(int id, String title, double balance)
      Constructs a Jar object with the specified ID, title, and balance but without a goal.
      Parameters:
      id - the ID of the jar
      title - the title of the jar
      balance - the current balance of the jar
  • Method Details

    • getId

      public int getId()
      Gets the ID of the jar.
      Returns:
      the ID of the jar
    • getTitle

      public String getTitle()
      Gets the title of the jar.
      Returns:
      the title of the jar
    • getGoal

      public double getGoal()
      Gets the goal amount of the jar.
      Returns:
      the goal amount of the jar
    • getBalance

      public double getBalance()
      Gets the current balance of the jar.
      Returns:
      the current balance of the jar