0% found this document useful (0 votes)
32 views1 page

Store Item Class Implementation

The document defines a Java class named Product1 that represents a store item with attributes such as name, product number, price, and quantity. It includes a constructor for initializing these attributes and getter methods for accessing their values. Additionally, it overrides the toString method to provide a formatted string representation of the product details.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views1 page

Store Item Class Implementation

The document defines a Java class named Product1 that represents a store item with attributes such as name, product number, price, and quantity. It includes a constructor for initializing these attributes and getter methods for accessing their values. Additionally, it overrides the toString method to provide a formatted string representation of the product details.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

/**

* Represents a single store item with details such as name, product number, price,
and quantity.
*
* Aksh Ladegaonkar
* APR 12, 2025
*/
public class Product1 {
private String name;
private int productNumber;
private double price;
private int quantity;

public Product1(String name, int productNumber, double price, int quantity) {


this.name = name;
this.productNumber = productNumber;
this.price = price;
this.quantity = quantity;
}

public String getName() {


return name;
}
public int getProductNumber() {
return productNumber;
}
public double getPrice() {
return price;
}
public int getQuantity() {
return quantity;
}

public String toString() {


return String.format("%-15s%-12d$%-12.2f%d", name, productNumber, price,
quantity);
}
}

You might also like