Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.alma.alt.Objects;
- /**
- * Created by alt on 17/06/2018.
- */
- public class Product implements Comparable<Product> {
- private String name;
- private double price;
- private double weight;
- private Type type;
- public Product(String name, double price, double weight, Type type) {
- this.name = name;
- this.price = price;
- this.type = type;
- this.weight = weight;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public double getPrice() {
- return price;
- }
- public void setPrice(double price) {
- this.price = price;
- }
- public Type getType() {
- return type;
- }
- public void setType(Type type) {
- this.type = type;
- }
- public double getWeight() {
- return weight;
- }
- public void setWeight(double weight) {
- this.weight = weight;
- }
- @Override
- public int compareTo(Product p) {
- double lastCmp = this.price.compareTo(p.getPrice());
- return (lastCmp != 0 ? lastCmp : this.price.compareTo(p.getPrice()));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement