/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.calebfontenot.lab3_calebfontenot;

import java.util.Date;
import java.util.Objects;

/**
 *
 * @author caleb
 */
public class Account {

    public Account()
    {
        dateCreated = new Date();
    }
    public Account(double balance) {
        this.balance = balance;
        dateCreated = new Date();
    }

    @Override
    public String toString()
    {
        return "Account{" + "id=" + id + ", balance=" + balance + ", dateCreated=" + dateCreated + '}';
    }
    
    private int id;
    private double balance;
    private static int annualInterestRate;
    private Date dateCreated;

    /**
     * Get the value of id
     *
     * @return the value of id
     */
    public int getId()
    {
        return id;
    }

    /**
     * Set the value of id
     *
     * @param id new value of id
     */
    public void setId(int id)
    {
        this.id = id;
    }

    /**
     * Get the value of balance
     *
     * @return the value of balance
     */
    public double getBalance()
    {
        return balance;
    }

    /**
     * Set the value of balance
     *
     * @param balance new value of balance
     */
    public void setBalance(double balance)
    {
        this.balance = balance;
    }



    /**
     * Get the value of annualInterestRate
     *
     * @return the value of annualInterestRate
     */
    public static int getAnnualInterestRate()
    {
        return annualInterestRate;
    }

    /**
     * Set the value of annualInterestRate
     *
     * @param annualInterestRate new value of annualInterestRate
     */
    public static void setAnnualInterestRate(int annualInterestRate)
    {
        Account.annualInterestRate = annualInterestRate;
    }
    public static void main(String[] args)
    {
        Account account1 = new Account();
        Account account2 = new Account(100);
        
        System.out.println(account1);
        System.out.println(account2);
        System.out.println(account1.equals(account2));
        System.out.println(account1.equals(new A()));
        
    }
    public void withdraw(double amount) {
            this.balance -= amount;
        }
    // public void withdraw(double amount) {
    //        this.balance -= amount;
    //    }

    @Override
    public int hashCode()
    {
        int hash = 3;
        return hash;
    }

    @Override
    public boolean equals(Object obj)
    {
        // If the parameter obj is the same as this object
        if (this == obj)  { // compare addresses
            return true;
        }
        if (obj == null) { // parameter is null
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        // here we are certain
        final Account other = (Account) obj;
        if (this.id != other.id) {
            return false;
        }
        if (Double.doubleToLongBits(this.balance) != Double.doubleToLongBits(other.balance)) {
            return false;
        }
        return Objects.equals(this.dateCreated, other.dateCreated);
    }
    
}class A {}
