Question: use java please Implement a class according to its UML class symbol: Product -name: String -price: double -scanCode: int -numObjects: int = 0 +Product (String,

 use java please Implement a class according to its UML class

use java please

Implement a class according to its UML class symbol: Product -name: String -price: double -scanCode: int -numObjects: int = 0 +Product (String, double) +getName(): String +getScanCode: int +getPrice(): double +changePrice (double): void +getNumObjects(): int +getNumberInstock(): int The constructor shall take two parameters to initialise the name and price fields. The variable numObjects shall be incremented by the constructor every time a new object is instattiated. The scanCode is a 4-digit integer value 1000 +numObjects initialised by the constructor. Test the defined class with the following program: class TestProduct {public static void main (String[] args) {System.out.println ("There are " + Product.getNumberInStock() + "items"); Product pr1 = new Product ("Computer", 1500.0); System.out.println ("There are" + Product.getNumberInstock() + "items"); Product pr2 = new Product ("Printer", 600.0); Product pr3 = new Product ("Monitor", 240.0); System.out.println ("There are" + Product.getNumberInstock() + "items"); Product pr2 = new Product ("Printer", 600.0); Product pr3 = new Product ("Monitor", 240.0); System.out.println ("There are" +Product.getNumberInstock () + "items"); pr2.changePrice (550.0); System.out.println("-- Product info -"); System.out.println (" Name: " + pr2. getName ()); System.out.println (" Scan code: " + pr2.getNumObjects ()); System.out.println ("price: " + pr2.getPrice ());}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!