Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solve on java programing language Question 1: (a) Develop a Java class that represents a product as follows: The product should have a description and

Solve on java programing language image text in transcribed
Question 1: (a) Develop a Java class that represents a product as follows: The product should have a description and a price and an ID Apply the principle of encapsulation by making the description and price private, and provide appropriate setter and getter methods for them. Make the ID public Define a default constructor, which generates a random number for the ID, and set the price to 10, and the description to "Unknown Define the toString method for the class to return an appropriate description of the product (b) Based on the Product class in part (a), complete the following main program: Public class Test Product Public static void main(String[] args) { 1/1. Create two objects, item1 and item2, with the following values. Object name item1 item2 Description Book Pencil Price 54.50 20 1/2. Increment the price of item1 by 10. //3. Print the total prices of item1 and item2 1/4. Change the description of item 1 to "Java Book 1/6. Use toString method to print item2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

assess the infl uence of national culture on the workplace

Answered: 1 week ago