Question: Please see the Checklist section below. The following sections describe the coding challenge. AlienEncounter AlienEncounter has an ivar energy that will provide the getEnergy value

Please see the "Checklist" section below. The following sections describe the coding challenge.

AlienEncounter

AlienEncounter has an ivar "energy" that will provide the "getEnergy" value that will make the interface EnergyEventIdea happy. Instructions

  • Add class named "AlienEncounter"
  • Have the class implement the "EnergyEventIdea" interface
  • Add ivar "energy" of type "int"
  • Add a constructor with one parameter that sets the ivar
  • Add getter and setter for ivar
  • Add all methods required by implemented interface (also see note above)

SpaceStationVisit

SpaceStationVisit has an ivar "fuel" that will provide the "getEnergy". We can assume that getEnergy will use fuel directly (i.e. simply return it as-is). Maybe later, we'll do fancy conversions. Instructions:

  • Add class named "SpaceStationVisit"
  • Have the class implement the "EnergyEventIdea" interface
  • Add ivar "fuel" of type "int"
  • Add a constructor with one parameter that sets the ivar
  • Add getter and setter for ivar
  • Add all methods required by implemented interface (also see note above)

EnergyCalculator

The brains of the operation but a simple class. Instructions:

  • Add class named "EnergyCalculator"
  • Add ivar "energySources" of type "List" (from Java lib) with element type "E" of EnergyEventIdea
  • Add ivar "totalEnergy" of type "int"
  • Add a constructor with one parameter that sets the "energySources" ivar
  • Add getter for "totalEnergy" ivar
  • Add instance method "compute" that has no params and no return. This method computes the total energy which is the sum of "getEnergy" for each EnergyEventIdea in our ivar "energySources".

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!