EldiraSesto

Resistor

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