EldiraSesto

Capacitor

Mar 18th, 2020
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 KB | None | 0 0
  1. package model;
  2.  
  3. import java.util.Objects;
  4.  
  5. public class Capacitor extends HardwareComponent { //Eldira Sesto, 11815163
  6.  
  7.     private float capacitorValue;
  8.  
  9.     /*public Capacitor(String id, float price) {
  10.         super(id, price);
  11.     }*/
  12.  
  13.     public Capacitor(String id, float price, float capacitorValue) {
  14.         super(id, price);
  15.         this.capacitorValue = capacitorValue;
  16.     }
  17.  
  18.     public float getCapacitorValue() {
  19.         return capacitorValue;
  20.     }
  21.  
  22.     public void setCapacitorValue(float capacitorValue) {
  23.         this.capacitorValue = capacitorValue;
  24.     }
  25.  
  26.     @Override
  27.     public boolean equals(Object o) {
  28.         if (this == o) return true;
  29.         if (o == null || getClass() != o.getClass()) return false;
  30.         if (!super.equals(o)) return false;
  31.         Capacitor capacitor = (Capacitor) o;
  32.         return Float.compare(capacitor.getCapacitorValue(), getCapacitorValue()) == 0;
  33.     }
  34.  
  35.     @Override
  36.     public String toString() {
  37.         return "Capacitor " + super.toString() + "<" + getCapacitorValue() + ">";
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment