Homework Solution: We will create a web-based application to maintain products for an online music catalog…

    Problem We will create a web-based application to maintain products for an online music catalog. Your task is to create a Java Bean that adheres to the following conventions: has a zero-argument constructor has properties whose values can only be accessed by accessor methods is Serializable, that is, implements the java.io.Serializable interface. Specification The bean must have the following features:
    Project Name aaannn_HW2_ProductMaint, where aaa - your initials, nnn - last 3 digits of your tech ID
    Package Prefix classes you create must be in packages that begin with the prefix: edu.metrostate.ics425.aaannn.prodmaint where aaa - your initials, nnn - last 3 digits of your tech ID note: per Java coding conventions characters in the package name should be all lower-case
    Class Name:  ProductBean.java
    Implements: edu.metrostate.ics.prodmaint.model.Product
    
    Properties:
    Property Name Type Access Description/ Notes
    Code String R/W Unique to each catalog entry
    Description String R/W Title of album
    Price double R/W Price of album
    Release Date java.time.LocalDate R/W Date album was released note: uses new Java8 time class
    Years Released int RO number of whole years from release date, or -1 if future release; -2 if no release date is set (i.e. releaseDate == null)
    Overrides: equals(Object) : so that products with the same code are equal (Case insensitive) hashCode() : should almost always be overridden to comply with relationship with equals (see Javadoc on Object) toString() : for convenience have it display something meaningful about the product Note: no main method is specified or required
    Demo App (optional) So you can test your bean without using a main method, I would recommend creating a demo application with the following use-case:
    System User
    1. Displays Product Entry Form 2. Enters product information and presses submit button
    3. System creates new product 4. System gets product information from request and sets product values 5. System displays Product Information Form displaying new product
    end of use case
    Note: no validation is required for this test app
    Provided: edu.metrostate.ics425.Product.java – the Product interface. Note: do not change its package. NOTE: this is Java Netbeans

    Expert Answer

     
    PROGRAM CODE: import java.io.Serializable;

    Problem

    We conciliate invent a web-grounded application to support effects coercion an online voice catalog. Your operation is to invent a Java Bean that adheres to the aftercited conventions:

    has a zero-argument constructor

    has properties whose values can merely be accessed by accessor systems

    is Serializable, that is, implements the java.io.Serializable interface.

    Specification

    The bean must possess the aftercited features:

    Project Call aaannn_HW2_ProductMaint,

    where aaa – your initials, nnn – last 3 digits of your tech ID

    Load Prefix classes you invent must be in loads that start with the prefix:
    edu.metrostate.ics425.aaannn.prodmaint

    where aaa – your initials, nnn – last 3 digits of your tech ID

    note: per Java coding conventions characters in the load call should be all lower-case

    Class Name:  ProductBean.java

    Implements: edu.metrostate.ics.prodmaint.model.Product
    

    Properties:

    Property Call Type Access Description/ Notes
    Code String R/W Unique to each catalog entry
    Description String R/W Title of album
    Price double R/W Value of album
    Disengage Era java.time.LocalDate R/W Era album was disengaged
    note: conservations innovating Java8 span class
    Years Disengaged int RO number of total years from disengage era, or

    -1 if coercionthcoming disengage;

    -2 if no disengage era is fixed (i.e. disengageEra == trifling)

    Overrides:

    equals(Object) : so that effects with the similar statute are resembling (Case impassible)

    hashCode() : should almost regularly be overridden to relinquish with interdependence with resemblings (understand Javadoc on Object)

    toString() : coercion retirement possess it expose something meaningful encircling the effect

    Note: no deep system is certain or required

    Demo App (optional) So you can experience your bean quenchedside using a deep system, I would praise creating a demo application with the aftercited conservation-case:

    System User
    1. Exposes Effect Entry Coercionm 2. Enters effect counsel and presses refer button
    3. System invents innovating effect

    4. System gets effect counsel from solicit and fixeds effect values

    5. System exposes Effect Counsel Coercionm exposeing innovating effect

    end of conservation case

    Note: no validation is required coercion this experience app

    Provided:

    edu.metrostate.ics425.Product.java – the Effect interface. Note: do not change its load.

    NOTE: this is Java Netbeans

    Expert Solution

     

    PROGRAM CODE:

    import java.io.Serializable;

    import java.time.LocalDate;

    //Class effect bean

    public class EffectBean implements Serializable{

    //private members of the class

    private String Statute;

    private String Description;

    private inclose value;

    private LocalEra DisengageDate;

    private int YearsReleased;

     

    //constructor that initializes members to absence values

    public EffectBean() {

    Statute = “”;

    Description = “”;

    value = 0;

    ReleaseEra = trifling;

    YearsReleased = -2;

    }

    //Accessor and mutator systems

    public String getCode() {

    give-back Statute;

    }

    public unfilled fixedCode(String statute) {

    Statute = statute;

    }

    public String getDescription() {

    give-back Description;

    }

    public unfilled fixedDescription(String description) {

    Description = description;

    }

    public inclose getPrice() {

    give-back value;

    }

    public unfilled fixedPrice(inclose value) {

    this.value = value;

    }

    public LocalEra getReleaseDate() {

    give-back DisengageDate;

    }

    public unfilled fixedReleaseDate(LocalEra disengageDate) {

    ReleaseEra = disengageDate;

    //updating years grounded on the disengage era

    if(releaseDate.isAfter(LocalDate.now()))

    YearsReleased = -1;

    else

    {

    YearsReleased = LocalDate.now().getYear() – disengageDate.getYear();

    }

    }

    //merely accessor

    public int getYearsReleased() {

    give-back YearsReleased;

    }

    @Override

    public boolean resemblings(Object obj) {

    ProductBean prod = (ProductBean)obj;

    if(Code.equalsIgnoreCase(prod.getCode()))

    give-back true;

    else give-back false;

    }

     

    @Override

    public int hashCode() {

    give-back Statute.hashCode();

    }

     

    @Override

    public String toString() {

    String effect = “Code: ” + Statute + “nDescription: ” + Description + “nPrice: $” + value + “nDisengage Era: ”

    + DisengageEra + “nYears Disengaged: “;

    if(YearsReleased == -1)

    effect += “Yet to be disengaged”;

    else if(YearsReleased == -2)

    effect += “NIL”;

    else effect += YearsReleased;

    give-back effect;

    }

     

    //merely coercion experienceing

    public static unfilled deep(String args[])

    {

    ProductBean bean = innovating EffectBean();

    bean.setCode(“RFH203”);

    bean.setDescription(“Innovating Year’s Eve”);

    bean.setPrice(23);

    bean.setReleaseDate(LocalDate.of(2011, 02, 21));

    System.out.println(bean);

    }

    }

    OUTPUT: