Light bulbs can be identified by type and can be measured by the amount of lumens produced per watt of power. The Incandescent and Fluorescent classes below inherit from the abstract LightBulb class. Complete the LightBulb class so that the getDescription method returns a string of the form lumensPerWatt=...,shape=... (without any spaces). Be sure that your class is abstract!

Complete the following file:

LightBulb.java

/** Represents a light bulb of some type. */ public abstract class LightBulb // MUST be abstract { // TODO: Add any needed instance variables, constructors, and methods /** Gets a description of this light bulb. @return a string of the form lumensPerWatt=...,shape=... (without any spaces) */ public String getDescription() { // TODO: Complete this method } }

Use the following files:

Fluorescent.java

/**
   Describes a fluorescent light bulb.  May have a shape such as tube
   or spiral.
*/
public class Fluorescent extends LightBulb
{
   private String shape;

   public Fluorescent(double lumens, String aShape)
   {
      super(lumens);
      shape = aShape;
   }

   public String getShape()
   {
      return shape;
   }
}

Incandescent.java

/**
   Represents an old-fashioned incandescent light bulb.
*/

public class Incandescent extends LightBulb
{
   public Incandescent(double lumens)
   {
      super(lumens);
   }

   public String getShape()
   {
      return "bulb";
   }
}

LightBulbTester.java

public class LightBulbTester
{
   public static void main(String[] args)
   {
      LightBulb bulb1 = new Incandescent(20);
      System.out.println(bulb1.getDescription());
      System.out.println("Expected: lumensPerWatt=20.0,shape=bulb");
      LightBulb bulb2 = new Fluorescent(62, "spiral");
      System.out.println(bulb2.getDescription());
      System.out.println("Expected: lumensPerWatt=62.0,shape=spiral");
      LightBulb bulb3 = new Fluorescent(72, "tube");
      System.out.println(bulb3.getDescription());
      System.out.println("Expected: lumensPerWatt=72.0,shape=tube");
   }
}