12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- package classes;
- public class HolonElement {
- /* Name of the gadget */
- String name;
- /* Quantity */
- int amount;
- /* Energy per gadget */
- float energy;
- /* If the gadget is working xor not (true xor false) */
- boolean isWorking;
- /* Total Energy */
- float totalEnergy;
- /* Path of the image for the Obj. */
- String image;
- public HolonElement(String name, int amount, float energy) {
- this.name = name;
- this.amount = amount;
- this.energy = energy;
- this.isWorking = true;
- // System.out.println("You create some " + name + "'s. The amount is:" +
- // amount);
- // System.out.println("It's actual status is: " + isWorking);
- }
- public HolonElement(HolonElement hol) {
- this.name = hol.getName();
- this.amount = hol.getAmount();
- this.energy = hol.getEnergy();
- this.isWorking = true;
- // System.out.println("You create some " + name + "'s. The amount is:" +
- // amount);
- // System.out.println("It's actual status is: " + isWorking);
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public int getAmount() {
- return amount;
- }
- public void setAmount(int amount) {
- this.amount = amount;
- }
- public float getEnergy() {
- return energy;
- }
- public void setEnergy(float energy) {
- this.energy = energy;
- }
- public void switchGadget(boolean bool) {
- this.isWorking = bool;
- }
- public boolean getState() {
- return isWorking;
- }
- /* Image path */
- public String getImage() {
- return image;
- }
- public void setImage(String image) {
- this.image = image;
- }
- /**
- * Multiply the amount of gadgets, given by the user, and the
- * consumption/production. If the switch isWorking is turned off for on
- * gadget, the energy of this gadget have to be subtracted
- *
- * @return totalEnergy (actual)
- */
- public float getTotalEnergy() {
- totalEnergy = ((float) amount) * energy;
- return totalEnergy;
- }
- }
|