Skip to content

Commit

Permalink
Merge pull request #104 from Tanisha0708/patch-3
Browse files Browse the repository at this point in the history
 improvements doneClass Naming: Changed the class name to Fine for cl…
  • Loading branch information
ajaynegi45 authored Nov 12, 2024
2 parents 1ea359d + 1b25369 commit 6880ceb
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 6880ceb

Please sign in to comment.