107 lines
3.0 KiB
Java
107 lines
3.0 KiB
Java
package Shop;
|
|
import java.util.*;
|
|
|
|
public class Products {
|
|
private double grossWorth;
|
|
private String Name;
|
|
private double weight;
|
|
private 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 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;
|
|
}
|
|
|
|
// Brutto Preis
|
|
public double getGrossPrice() {
|
|
return this.netWorth * (1 + this.tax / 100);
|
|
}
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|