Online-Shop/Products.java

112 lines
3.1 KiB
Java

package Shop;
import java.util.*;
public class Products {
private double grossWorth;
private String Name;
private double weight;
private static double netWorth;
private double tax;
private int productID;
private int stock;
// Constructor for the Products class
public Products(String Name, double weight, double netWorth, double tax, int stock, int productID) {
this.Name = Name;
this.weight = weight;
this.netWorth = netWorth;
this.tax = tax;
this.stock = stock;
this.productID = productID;
}
public int getProductID() {
return productID;
}
public void setProductID(int productID) {
this.productID = productID;
}
public String getName() {
return Name;
}
public void setName(String name) {
this.Name = name;
}
public void setWeight(double weight) {
this.weight = weight;
}
public double getWeight() {
return weight;
}
public static double getNetWorth() {
return netWorth;
}
public void setNetWorth(double netWorth) {
this.netWorth = netWorth;
}
public double getTax() {
return tax;
}
public void setTax(double newTax) {
this.tax = newTax;
}
public int getStock() {
return this.stock;
}
//neuer Bestand setzen
public void setStock(int newStock) {
this.stock = newStock;
}
public double getGrossPrice() {
return this.netWorth * (1 + this.tax);
}
public double getTaxAmount() {
return this.getGrossPrice() - this.netWorth;
}
public String toString() {
return
"ID:" + this.productID + ", \n" //1. ID
+ "Name: " + this.Name + ", \n" //2. Name
+ "Gewicht: " + this.weight + " Kg, \n" //3. Gewicht
+ "Preis: " + this.netWorth + " Euro, \n" //4. Nettopreis
+ "MwSt-Satz: " + this.tax + " %, \n" //5. MwSt-Satz
+ "Lagerbestand: "+ this.stock + " Stück"; //6. Lagerbestand
}
@Override
public int hashCode() {
return Objects.hash(Name, netWorth);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Products other = (Products) obj;
return Objects.equals(Name, other.Name)
&& Double.doubleToLongBits(netWorth) == Double.doubleToLongBits(other.netWorth);
}
}