Answered Essay: 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;

import java.time.LocalDate;

//Class product bean

public class ProductBean implements Serializable{

//private members of the class

private String Code;

private String Description;

private double price;

private LocalDate ReleaseDate;

private int YearsReleased;

 

//constructor that initializes members to default values

public ProductBean() {

Code = “”;

Description = “”;

price = 0;

ReleaseDate = null;

YearsReleased = -2;

}

//Accessor and mutator methods

public String getCode() {

return Code;

}

public void setCode(String code) {

Code = code;

}

public String getDescription() {

return Description;

}

public void setDescription(String description) {

Description = description;

}

public double getPrice() {

return price;

}

public void setPrice(double price) {

this.price = price;

}

public LocalDate getReleaseDate() {

return ReleaseDate;

}

public void setReleaseDate(LocalDate releaseDate) {

ReleaseDate = releaseDate;

//updating years based on the release date

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

YearsReleased = -1;

else

{

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

}

}

//only accessor

public int getYearsReleased() {

return YearsReleased;

}

@Override

public boolean equals(Object obj) {

ProductBean prod = (ProductBean)obj;

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

return true;

else return false;

}

 

@Override

public int hashCode() {

return Code.hashCode();

}

 

@Override

public String toString() {

String result = “Code: ” + Code + “nDescription: ” + Description + “nPrice: $” + price + “nRelease Date: ”

+ ReleaseDate + “nYears Released: “;

if(YearsReleased == -1)

result += “Yet to be released”;

else if(YearsReleased == -2)

result += “NIL”;

else result += YearsReleased;

return result;

}

 

//only for testing

public static void main(String args[])

{

ProductBean bean = new ProductBean();

bean.setCode(“RFH203”);

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

bean.setPrice(23);

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

System.out.println(bean);

}

}

OUTPUT:

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.

× How can I help you?