Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

**In Java Turn NonFiction category code into an enumerated type with possible va

ID: 3683180 • Letter: #

Question

**In Java

Turn NonFiction category code into an enumerated type with possible values of biography, technology, history, science, autobiography.

public class NonFiction extends Book
{
   private String categorycode;

   public NonFiction()
   {
       super();
       setCategorycode("");
   }

   public NonFiction(String title, String author, Publisher publisher, String isbn, double price, String categorycode)
   {
       super(title, author, publisher, isbn, price);
       setCategorycode(categorycode);
   }
  
   public void setCategorycode(String categorycode)
   {
       this.categorycode = categorycode;
   }

   public String getCategorycode()
   {
       return categorycode;
   }
  
   public String toString()
   {
       return(super.toString() + " Category Code " + categorycode);
   }
}

Explanation / Answer

// Please give the full program since I can't fix the errors without the full code
public class NonFiction extends Book
{
   public enum Category {
       biography,
       technology,
       history,
       science
   }
private Category categorycode;
public NonFiction()
{
super();
setCategorycode("");
}
public NonFiction(String title, String author, Publisher publisher, String isbn, double price, Category categorycode)
{
super(title, author, publisher, isbn, price);
setCategorycode(categorycode);
}
  
public void setCategorycode(Category categorycode)
{
this.categorycode = categorycode;
}
public Category getCategorycode()
{
return categorycode;
}
  
public String toString()
{
return(super.toString() + " Category Code " + categorycode);
}
}