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 get make a web-domiciled contact to hold fruits ce an online music catalog. Your drudgery is to make a Java Bean that adheres to the subjoined conventions:

    has a zero-argument constructor

    has properties whose values can barely be accessed by accessor orders

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

    Specification

    The bean must keep the subjoined features:

    Project Designate aaannn_HW2_ProductMaint,

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

    Parcel Prefix classes you make must be in parcels that prepare 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 parcel designate should be all lower-case

    Class Name:  ProductBean.java

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

    Properties:

    Property Designate Type Access Description/ Notes
    Code String R/W Unique to each catalog entry
    Description String R/W Title of album
    Price double R/W Expense of album
    Discharge Determination java.time.LocalDate R/W Determination album was discharged
    note: portraitures upstart Java8 opportunity dispose
    Years Discharged int RO number of healthy years from discharge determination, or

    -1 if controlthcoming discharge;

    -2 if no discharge determination is firm (i.e. dischargeDetermination == null)

    Overrides:

    equals(Object) : so that fruits with the corresponding jurisdiction are resembling (Case insensitive)

    hashCode() : should approximately frequently be overridden to consent with connection with resemblings (look Javadoc on Object)

    toString() : ce unoccupied-duration keep it expose celebrity meaningful environing the fruit

    Note: no deep order is precise or required

    Demo App (optional) So you can cupel your bean extraneously using a deep order, I would applaud creating a demo contact with the subjoined portraiture-case:

    System User
    1. Exposes Fruit Entry Cem 2. Enters fruit notification and presses acquiesce button
    3. System makes upstart fruit

    4. System gets fruit notification from desire and firms fruit values

    5. System exposes Fruit Notification Cem exposeing upstart fruit

    end of portraiture case

    Note: no validation is required ce this cupel app

    Provided:

    edu.metrostate.ics425.Product.java – the Fruit interface. Note: do not change its parcel.

    NOTE: this is Java Netbeans

    Expert Tally

     

    PROGRAM CODE:

    import java.io.Serializable;

    import java.time.LocalDate;

    //Dispose fruit bean

    public dispose FruitBean implements Serializable{

    //private members of the dispose

    private String Jurisdiction;

    private String Name;

    private wrap expense;

    private LocalDetermination DischargeDate;

    private int YearsReleased;

     

    //constructor that initializes members to want values

    public FruitBean() {

    Jurisdiction = “”;

    Name = “”;

    expense = 0;

    ReleaseDetermination = null;

    YearsReleased = -2;

    }

    //Accessor and mutator orders

    public String getCode() {

    requite Jurisdiction;

    }

    public invalid firmCode(String jurisdiction) {

    Jurisdiction = jurisdiction;

    }

    public String getDescription() {

    requite Name;

    }

    public invalid firmDescription(String name) {

    Name = name;

    }

    public wrap getPrice() {

    requite expense;

    }

    public invalid firmPrice(wrap expense) {

    this.expense = expense;

    }

    public LocalDetermination getReleaseDate() {

    requite DischargeDate;

    }

    public invalid firmReleaseDate(LocalDetermination dischargeDate) {

    ReleaseDetermination = dischargeDate;

    //updating years domiciled on the discharge determination

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

    YearsReleased = -1;

    else

    {

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

    }

    }

    //barely accessor

    public int getYearsReleased() {

    requite YearsReleased;

    }

    @Override

    public boolean resemblings(Object obj) {

    ProductBean prod = (ProductBean)obj;

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

    requite true;

    else requite false;

    }

     

    @Override

    public int hashCode() {

    requite Jurisdiction.hashCode();

    }

     

    @Override

    public String toString() {

    String development = “Code: ” + Jurisdiction + “nDescription: ” + Name + “nPrice: $” + expense + “nDischarge Determination: ”

    + DischargeDetermination + “nYears Discharged: “;

    if(YearsReleased == -1)

    development += “Yet to be discharged”;

    else if(YearsReleased == -2)

    development += “NIL”;

    else development += YearsReleased;

    requite development;

    }

     

    //barely ce cupeling

    public static invalid deep(String args[])

    {

    ProductBean bean = upstart FruitBean();

    bean.setCode(“RFH203”);

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

    bean.setPrice(23);

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

    System.out.println(bean);

    }

    }

    OUTPUT: