Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package model;
- import java.util.Objects;
- public abstract class HardwareComponent { //Eldira Sesto, 11815163
- private String id;
- private float price;
- public HardwareComponent(String id, float price) {
- this.id = id;
- this.price = price;
- }
- public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
- public float getPrice() {
- return price;
- }
- public void setPrice(float price) {
- this.price = price;
- }
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- HardwareComponent that = (HardwareComponent) o;
- return Float.compare(that.getPrice(), getPrice()) == 0 &&
- getId().equals(that.getId());
- }
- @Override
- public String toString() {
- return getId() + " (" + getPrice() + ") ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment