Question

public enum Rating {               GENERAL(0),        PARENTALGUIDANCE(1),        MATURE(2);     

public enum Rating {

      

       GENERAL(0),

       PARENTALGUIDANCE(1),

       MATURE(2);

      

       private int minAge;

      

       private Rating(int i)

       {

             minAge = i;

       }

      

       public int getMinAge()

       {

             return minAge;

       }

      

       public void setMinAge(int age)

       {

             minAge = age;

       }

      

       public String toString()

       {

             switch(this)

             {

             case GENERAL:

                    return "G";

             case PARENTALGUIDANCE:

                    return "P";

             case MATURE:

                    return "M";

             }

            

             return "";

       }

}

//end of Rating.java

//Film.java

public class Film {

      

       private String title;

       private Rating rating;

      

       public Film()

       {

             title="";

             rating = null;

       }

      

       public Film(String title, Rating rating)

       {

             this.title = title;

             this.rating = rating;

       }

      

       public String getTitle()

       {

             return title;

       }

      

       public void setTitle(String title)

       {

             this.title = title;

       }

      

       public Rating getRating()

       {

             return rating;

       }

      

       public void setRating(Rating rating)

       {

             this.rating = rating;

       }

      

       public String toString()

       {

             return title+" rating : ("+rating+")";

       }

}

//end of Film.java

//Customer.java

public class Customer {

      

       private String name;

       private int age;

       private boolean isStudent;

      

       public Customer()

       {

             name="";

             age = 0;

             isStudent = false;

       }

      

       public Customer(String name, int age, boolean isStudent)

       {

             this.name = name;

             this.age = age;

             this.isStudent = isStudent;

       }

      

       public String getName()

       {

             return name;

       }

      

       public void setName(String name)

       {

             this.name = name;

       }

      

       public int getAge()

       {

             return age;

       }

      

       public void setAge(int age)

       {

             this.age = age;

       }

      

       public boolean isStudent()

       {

             return isStudent;

       }

      

       public void setStudent(boolean isStudent)

       {

             this.isStudent = isStudent;

       }

      

       public String toString()

       {

             String studStr = name+" age :"+age+" Student? ";

             if(isStudent)

                    studStr += "Yes";

             else

                    studStr += "No";

            

             return studStr;

       }

}

//end of Customer.java

=======================================================

= Please can you provide comments on the code, thank you so much!! =

=======================================================

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/**
* Rating that can be used
*/
public enum Rating {

/**
    * GENERAL Rating
    */
      
GENERAL(0),
  
/**
    * PARENTALGUIDANCE Rating
    */

PARENTALGUIDANCE(1),

/**
    * MATURE Rating
    */

MATURE(2);

  
/** private data member for minimum age **/
private int minAge;

  
/** parameterized constructor **/
private Rating(int i)
{

minAge = i;

}

  
/** method to return the value of minAge **/
public int getMinAge()
{

return minAge;

}

  
/** method to set the value of minAge **/
public void setMinAge(int age)
{

minAge = age;

}

  
@Override
/** method to return the information of Rating in form of a String **/
public String toString()
{
/** switch statement **/
switch(this)

{

case GENERAL:

return "G";

case PARENTALGUIDANCE:

return "P";

case MATURE:

return "M";

}
  

return "";

}

}

//end of Rating.java

//Film.java

/**** Film class ****/
public class Film {

/** private data member for Film title **/
private String title;
/** private data member for Film rating **/
private Rating rating;

  
/** parameterless constructor **/
public Film()
{

title="";

rating = null;

}

  
/** parameterized constructor **/
public Film(String title, Rating rating)
{

this.title = title;

this.rating = rating;

}

  
/** method to return the title of the Film **/
public String getTitle()
{

return title;

}

  
/** method to set the title of the Film **/
public void setTitle(String title)
{

this.title = title;

}

  
/** method to return the rating of the Film **/
public Rating getRating()
{

return rating;

}

  
/** method to set the rating of the Film **/
public void setRating(Rating rating)
{

this.rating = rating;

}

  
@Override
/** method to return the information of the Film in form of a String **/
public String toString()
{

return title+" rating : ("+rating+")";

}

}

//end of Film.java

//Customer.java

/***** Customer class *****/
public class Customer {

  
/** private data members for customer's name **/
private String name;
/** private data members for customer's age **/
private int age;
/** private data members for denoting student or not **/
private boolean isStudent;

  
/** parameterless constructor **/
public Customer()
{

name="";

age = 0;

isStudent = false;

}

  
/** parameterized constructor **/
public Customer(String name, int age, boolean isStudent)

{

this.name = name;

this.age = age;

this.isStudent = isStudent;

}

  
/** method to return the name of the Customer **/
public String getName()

{

return name;

}

  
/** method to set the name of the Customer **/
public void setName(String name)

{

this.name = name;

}

  
/** method to return the age of the Customer **/
public int getAge()

{

return age;

}

  
/** method to set the age of the Customer **/
public void setAge(int age)

{

this.age = age;

}

  
/** method to return the value of isStudent **/
public boolean isStudent()

{

return isStudent;

}

  
/** method to set the value of isStudent **/
public void setStudent(boolean isStudent)

{

this.isStudent = isStudent;

}

@Override
/** method to return the information of the Student in form of a String **/
public String toString()

{

String studStr = name+" age :"+age+" Student? ";

/* check student or not */

if(isStudent)

studStr += "Yes";   

else

studStr += "No";

  

return studStr;

}

}

//end of Customer.java

Note: Whether you face any problem then share with me. I expect positive feedback from your end.

Add a comment
Know the answer?
Add Answer to:
public enum Rating {               GENERAL(0),        PARENTALGUIDANCE(1),        MATURE(2);     
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help converting the following two classes into one sql table package Practice.model; impor...

    I need help converting the following two classes into one sql table package Practice.model; import java.util.ArrayList; import java.util.List; import Practice.model.Comment; public class Students {          private Integer id;    private String name;    private String specialties;    private String presentation;    List<Comment> comment;       public Students() {}       public Students(Integer id,String name, String specialties, String presentation)    {        this.id= id;        this.name = name;        this.specialties = specialties;        this.presentation = presentation;        this.comment = new ArrayList<Commment>();                  }       public Students(Integer id,String name, String specialties, String presentation, List<Comment> comment)    {        this.id= id;        this.name...

  • Consider the Automobile class: public class Automobile {    private String model;    private int rating;...

    Consider the Automobile class: public class Automobile {    private String model;    private int rating; // a number 1, 2, 3, 4, 5    private boolean isTruck;    public Automobile(String model, boolean isTruck) {       this.model = model;       this.rating = 0; // unrated       this.isTruck = isTruck;    }        public Automobile(String model, int rating, boolean isTruck) {       this.model = model;       this.rating = rating;       this.isTruck = isTruck;    }                public String getModel()...

  • PLEASE COMPLETE THE CODES. package javaprogram; import java.io.PrintStream; import java.util.ArrayList; import java.util.Scanner; /** * Movie class...

    PLEASE COMPLETE THE CODES. package javaprogram; import java.io.PrintStream; import java.util.ArrayList; import java.util.Scanner; /** * Movie class definition. * * @author David Brown * @version 2019-01-22 */ public class Movie implements Comparable { // Constants public static final int FIRST_YEAR = 1888; public static final String[] GENRES = { "science fiction", "fantasy", "drama", "romance", "comedy", "zombie", "action", "historical", "horror", "war" }; public static final int MAX_RATING = 10; public static final int MIN_RATING = 0; /** * Converts a string of...

  • What is the final value of the count field? public class Person { private String name;...

    What is the final value of the count field? public class Person { private String name; private int age; private static int count=0; public Person(String name, int age) { this.name = name; this.age age; count++; } public static void main(String[] args) { Person a - new Person("John Doe". 35): Person b new Person("Jane Doe", 38): for(int i=0;i<5;i++) Person tempa

  • How to create a constructor that uses parameters from different classes? I have to create a...

    How to create a constructor that uses parameters from different classes? I have to create a constructor for the PrefferedCustomer class that takes parameters(name, address,phone number, customer id, mailing list status, purchase amount) but these parameters are in superclasses Person and Customer. I have to create an object like the example below....... PreferredCustomer preferredcustomer1 = new PreferredCustomer("John Adams", "Los Angeles, CA", "3235331234", 933, true, 400); System.out.println(preferredcustomer1.toString() + "\n"); public class Person { private String name; private String address; private long...

  • java questions: 1. Explain the difference between a deep and a shallow copy. 2. Given the...

    java questions: 1. Explain the difference between a deep and a shallow copy. 2. Given the below classes: public class Date {    private String month;    private String day;    private String year;    public Date(String month, String day, String year) {       this.month = month;       this.day = day;       this.year = year;    }    public String getMonth() {       return month;    }    public String getDay() {       return day;    }    public String...

  • C++ Language I have a class named movie which allows a movie object to take the...

    C++ Language I have a class named movie which allows a movie object to take the name, movie and rating of a movie that the user inputs. Everything works fine but when the user enters a space in the movie's name, the next function that is called loops infinetly. I can't find the source of the problem. Down below are my .cpp and .h file for the program. #include <iostream> #include "movie.h" using namespace std; movie::movie() { movieName = "Not...

  • 4. Command pattern //class Stock public class Stock { private String name; private double price; public...

    4. Command pattern //class Stock public class Stock { private String name; private double price; public Product(String name, double price) { this.name = name; this.price = price; } public void buy(int quantity){ System.out.println(“BOUGHT: “ + quantity + “x “ + this); } public void sell(int quantity){ System.out.println(“SOLD: “ + quantity + “x “ + this); } public String toString() { return “Product [name=” + name + “, price=” + price + “]”; } } a. Create two command classes that...

  • Assignment (to be done in Java): Person Class: public class Person extends Passenger{ private int numOffspring;...

    Assignment (to be done in Java): Person Class: public class Person extends Passenger{ private int numOffspring; public Person() {    this.numOffspring = 0; } public Person (int numOffspring) {    this.numOffspring = numOffspring; } public Person(String name, int birthYear, double weight, double height, char gender, int numCarryOn, int numOffspring) {    super(name, birthYear, weight, height, gender, numCarryOn);       if(numOffspring < 0) {        this.numOffspring = 0;    }    this.numOffspring = numOffspring; } public int getNumOffspring() {   ...

  • COVERT TO PSEUDOCODE /****************************Vacation.java*****************************/ public abstract class Vacation {    /*    * private data field...

    COVERT TO PSEUDOCODE /****************************Vacation.java*****************************/ public abstract class Vacation {    /*    * private data field    */    private double cost;    private double budget;    private String destination;    /**    *    * @param cost    * @param budget    * @param destination    */    public Vacation(double cost, double budget, String destination) {        super();        this.cost = cost;        this.budget = budget;        this.destination = destination;    }    //getter and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT