Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package rbvs.product;
- import ict.basic.IDeepCopy;
- import java.util.Objects;
- //Eldira Sesto, 11815163
- public abstract class Product implements IProduct {
- private String name;
- private float price;
- public Product(String name) {
- this.name = name;
- }
- public Product(String name, float price) {
- this.name = name;
- this.price = price;
- }
- @Override
- public String getname() {
- return this.name;
- }
- @Override
- public float getPrice() {
- return this.price;
- }
- public void setName(String name) {
- this.name = name;
- }
- public void setPrice(float price) {
- this.price = price;
- }
- @Override
- public abstract IDeepCopy deepCopy();
- @Override
- public final boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- Product product = (Product) o;
- return Objects.equals(name, product.name);
- }
- private void initialize (String name, float price){
- if(name == null){
- this.name = "";
- }else {
- this.name = name;
- }
- this.price = price;
- }
- @Override
- public String toString() {
- return "Product[" +
- "name='" + name + ',' +
- "price=" + price +
- ']';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement