Skip to content

Commit

Permalink
improvements doneClass Naming: Changed the class name to Fine for cl…
Browse files Browse the repository at this point in the history
…arity.

Precision and Scale: Correctly defined precision = 10 and scale = 2 in the @column annotation for amount to match your documentation.
Javadoc Comments: Added detailed Javadoc comments for fields and methods, explaining the purpose and parameters.
toString() Method: Added a toString() method for convenient debugging and logging.
fineId Column Definition: Set updatable = false for fineId as it should be immutable once generated.
  • Loading branch information
Tanisha0708 authored Nov 5, 2024
1 parent 00779eb commit 1b25369
Showing 1 changed file with 61 additions and 16 deletions.
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 +
'}';
}
}

0 comments on commit 1b25369

Please sign in to comment.