Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvements doneClass Naming: Changed the class name to Fine for cl… #104

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 61 additions & 16 deletions src/main/java/com/libraryman_api/fine/Fines.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,99 @@

import java.math.BigDecimal;

/**
* Represents a fine in the Library Management System.
* Each fine has an amount, a payment status, and a unique identifier.
*/
@Entity
public class Fines {
public class Fine {

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = "fine_id_generator")
@SequenceGenerator(name = "fine_id_generator",
sequenceName = "fine_id_sequence",
allocationSize = 1)
@Column(name = "fine_id")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "fine_id_generator")
@SequenceGenerator(name = "fine_id_generator", sequenceName = "fine_id_sequence", allocationSize = 1)
@Column(name = "fine_id", updatable = false, nullable = false)
private int fineId;

/**
* precision = 10 means the total number of digits (including decimal places) is 10.
* scale = 2 means the number of decimal places is 2.
*
* @Column(nullable = false, precision = 10, scale = 2)
* The amount of the fine with a precision of 10 and a scale of 2.
* Precision = 10 means the total number of digits (including decimal places) is 10.
* Scale = 2 means the number of decimal places is 2.
*/
@Column(nullable = false, scale = 2)
@Column(nullable = false, precision = 10, scale = 2)
private BigDecimal amount;

/**
* Indicates whether the fine has been paid.
*/
@Column(nullable = false)
private boolean paid = false;

public Fines() {
// Default constructor for JPA
public Fine() {
}

public Fines(BigDecimal amount, boolean paid) {
// Constructor with fields
public Fine(BigDecimal amount, boolean paid) {
this.amount = amount;
this.paid = paid;
}

/**
* Gets the unique ID of the fine.
*
* @return the unique fine ID
*/
public int getFineId() {
return fineId;
}

/**
* Gets the amount of the fine.
*
* @return the amount of the fine
*/
public BigDecimal getAmount() {
return amount;
}

/**
* Sets the amount of the fine.
*
* @param amount the amount to set
*/
public void setAmount(BigDecimal amount) {
this.amount = amount;
}

/**
* Checks if the fine has been paid.
*
* @return true if the fine is paid, false otherwise
*/
public boolean isPaid() {
return paid;
}

/**
* Sets the payment status of the fine.
*
* @param paid true if the fine is paid, false otherwise
*/
public void setPaid(boolean paid) {
this.paid = paid;
}

public int getFineId() {
return fineId;
/**
* Provides a string representation of the Fine object.
*
* @return a string containing the fine details
*/
@Override
public String toString() {
return "Fine{" +
"fineId=" + fineId +
", amount=" + amount +
", paid=" + paid +
'}';
}
}