[SOLVED] CS1331-Homework 5 Water Fountain

20.99 $

Category:

Description

Rate this product

The water fountain company that you work for wants to re-write the code for their water fountains. The production team has given you all the information that needs to be tracked by each water fountain. The sales team has also given you a few requirements for special features to help sell the updated models. Your job is to make a Java class to represent a water fountain that contains all the information and requirements you have received. Unfortunately, you are the only software developer at your job so you have to write everything yourself.

Solution Description

For this assignment create a file named WaterFountain.java. You will have to fill in the required instance variables and methods listed below.

Instance Variables:

  • String modelName
    • modelName should have private access and be used to hold the model name of the water fountain • boolean requiresMaintenance
    • requiresMaintenance should have private access and be used to hold if the water fountain requires maintenance or not.
  • int cupsPoured
    • cupsPoured should have private access and be used to hold the number of cups of water the water fountain has poured.

Static Variable:

  • int totalWaterFountains
    • totalWaterFountains should have private access and be used to hold the number of water fountains that have been created. It should be set to 0 by default.

Constant Variable:

  • String SOFTWARE_VERSION
    • SOFTWARE_VERSION should have public access, not be able to be changed, and should be able to be referenced statically. The variable should be set to “2.0.0”.

The Constructor:

The constructor should only take in values for modelName and cupsPoured and set each of them respectively. requiresMaintenance should be initialized to false and totalWaterFountains should be incremented by one.

The Methods:

All getters and setters should have public access.

  • Proper Getter & Setter for modelName
  • Proper Getter & Setter for requiresMaintenance
  • Proper Getter & Setter for cupsPoured
  • Proper Static Getter for totalWaterFountains
  • void pourCup()
    • This method takes no parameters, returns nothing, and has public access. If the water fountain does not require maintenance, cupsPoured should be incremented by one. If the water fountain does require maintenance, do nothing.
  • boolean equals(WaterFountain other)
    • This method takes in a WaterFountain, returns true if the other passed in water fountain is logically equal to this water fountain and false otherwise, and has public access. Water fountains are logically equal if they have the same modelName, cupsPoured, and SOFTWARE_VERSION.
  • String toString()
    • This method takes no parameters, returns a String, and has public access. This method will return a string that contains the water fountain’s modelName, requiresMaintenance, cupsPoured, and SOFTWARE_VERSION.
    • If the water fountain needs maintenance the returned string should match this: “[modelName] has poured [cupsPoured] cups, requires maintenance, and is running version: [SOFTWARE_VERSION]”
    • If the water fountain does not need maintenance then the returned string should match this: “[modelName] has poured [cupsPoured] cups, does not require maintenance, and is running version: [SOFTWARE_VERSION]”
    • Example: “A-222 has poured 987 cups, does not require maintenance, and is running version: 2.0.0”