SlideShare une entreprise Scribd logo
1  sur  3
Télécharger pour lire hors ligne
Design a class named Item by compiling a UML diagram for the class.
Item
-name: String
-numInStock: int
-costPrice: double
-sellingPrice: double
+Item()
+Item(name: String, costPrice:double)
+getName(): String
+getNumInStock(): int
+getCostPrice(): double
+setNumInStock(numStock: int): void
+setSellingPrice(percProfit: double): void
+calcStockValue(): double
+sellItems(numToSell:int)
The class should contain:
A string data field named name for the items name.
An int data field named numInStock that stores the number of the item in stock.
A double data field named costPrice that stores the price that the item was purchased for.
A double data field named sellingPrice that stores the price that the item must be sold for.
Two overloaded constructors:
A default (no-argument) constructor that creates a default account (receives no values)
A constructor with two parameters that receives the name and cost price of the item. Assign the
parameter values to the relevant instance fields. Assign the value of 0 to the numInStock instance
field and the value of the costPrice to the sellingPrice instance field.
Accessor methods for all the instance fields.
Two mutator methods:
setNumInStock() that receives a value as the number of stock. Assign the value to the relevant
instance field.
setSellingPrice(percProfit:double) that receives the percentage profit that should be made on
the cost price of the item. Calculate and assign the selling price to the sellingPrice instance field.
Use the following information to do the calculation:
sellingPrice = costPrice + (costPrice * percProfit/100)
A method named sellItems() that receives the number of items to be sold. If the number received
is greater than the number of items in stock, return the value -1 which indicates that no items were
sold. If there is enough stock, subtract the number received from the number in stock and return
the value of 0.
A method named calcStockValue() that calculates and returns the stock value of items using the
costPrice multiplied by the and the number of items in stock.
toString() method to compiled and return an output string in the following format:
Name of item: xxxxxx
Cost price: R xxxxx.xx
Number in stock: xx
Selling price: R xxxxx.xx
Do the following:
Write code for the Item class as described in the section above.
Write a test program named testItem that allows the user to enter the name of an item and the
cost price of the item.
Instantiates (creates) an Item object calling the parameterised constructor with the name and cost
price of the item as arguments.
Call the setNumInStock() method to set the number of items in stock to the value 10
Call the setSellingPrice() method using the value of 50 as the % profit to be made on the cost
price of the item.
Use the toString() method to display the information of the Item object.
Call the calcStockValue() and display the value as follows:
Value of items in stock: R xxxxxx.xx
Selling items:
Display the heading Selling items
Use while loop to allow the user to how many items must be sold. While there are items in stock
and the input of the user is more than 0 do the following:
Call the sellItems() method to sell the items. If the method returns the value of -1, display a
message indicating that there is not enough stock. Also display the number of items in stock by
calling the getNumInStock() method.
If there is enough stock, display a message indicating that the items were sold.
Also display the number of items in stock (after the sale) by calling the getNumInStock() method.
Example of output if the input is Bag as the name of the item and R150.00 as the cost price:
Name of item: Bag
Cost price: R 150.00
Number in stock: 10
Selling price: R 225.00
Value of items in stock: R 1500.00
Selling items:
Enter the number of items to sell (0 to quit):
4
Number of items sold: 4
Number of items in stock: 6
Enter the number of items to sell (0 to quit):
8
Not enough stock
Number of items in stock: 6
Enter the number of items to sell (0 to quit):
6
Number of items sold: 6
Number of items in stock: 0
Done.
Item
-name: String
-numInStock: int
-costPrice: double
-sellingPrice: double
+Item()
+Item(name: String, costPrice:double)
+getName(): String
+getNumInStock(): int
+getCostPrice(): double
+setNumInStock(numStock: int): void
+setSellingPrice(percProfit: double): void
+calcStockValue(): double
+sellItems(numToSell:int)

Contenu connexe

Similaire à Design a class named Item by compiling a UML diagram for the.pdf

C++ help finish my code Topics class definitions, arrays of objec.pdf
C++ help finish my code Topics class definitions, arrays of objec.pdfC++ help finish my code Topics class definitions, arrays of objec.pdf
C++ help finish my code Topics class definitions, arrays of objec.pdfinfo189835
 
vectors.(join ALL INDIA POLYTECHNIC (AICTE)).pptx
vectors.(join ALL INDIA POLYTECHNIC (AICTE)).pptxvectors.(join ALL INDIA POLYTECHNIC (AICTE)).pptx
vectors.(join ALL INDIA POLYTECHNIC (AICTE)).pptxVivekSharma34623
 
Lab exam 5_5_15
Lab exam 5_5_15Lab exam 5_5_15
Lab exam 5_5_15Daman Toor
 
12.9 Program Online shopping cart (continued) (C++)This program e.pdf
12.9 Program Online shopping cart (continued) (C++)This program e.pdf12.9 Program Online shopping cart (continued) (C++)This program e.pdf
12.9 Program Online shopping cart (continued) (C++)This program e.pdffasttracksunglass
 
© 2014 Laureate Education, Inc. Page 1 of 4 Retail Trans.docx
© 2014 Laureate Education, Inc.   Page 1 of 4 Retail Trans.docx© 2014 Laureate Education, Inc.   Page 1 of 4 Retail Trans.docx
© 2014 Laureate Education, Inc. Page 1 of 4 Retail Trans.docxLynellBull52
 
java I am trying to run my code but it is not letting me .pdf
java    I am trying to run my code but it is not letting me .pdfjava    I am trying to run my code but it is not letting me .pdf
java I am trying to run my code but it is not letting me .pdfadinathassociates
 
19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.ppt19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.pptAqeelAbbas94
 
Heap sort - Arafath Islam Sezan.pptx
Heap sort - Arafath Islam Sezan.pptxHeap sort - Arafath Islam Sezan.pptx
Heap sort - Arafath Islam Sezan.pptxArafath Islam Sezan
 
Write ItemList.h and ItemList.cItemList is used to store a list .pdf
Write ItemList.h and ItemList.cItemList is used to store a list .pdfWrite ItemList.h and ItemList.cItemList is used to store a list .pdf
Write ItemList.h and ItemList.cItemList is used to store a list .pdfsales223546
 

Similaire à Design a class named Item by compiling a UML diagram for the.pdf (14)

C++ help finish my code Topics class definitions, arrays of objec.pdf
C++ help finish my code Topics class definitions, arrays of objec.pdfC++ help finish my code Topics class definitions, arrays of objec.pdf
C++ help finish my code Topics class definitions, arrays of objec.pdf
 
DAY_1.3.pptx
DAY_1.3.pptxDAY_1.3.pptx
DAY_1.3.pptx
 
vectors.(join ALL INDIA POLYTECHNIC (AICTE)).pptx
vectors.(join ALL INDIA POLYTECHNIC (AICTE)).pptxvectors.(join ALL INDIA POLYTECHNIC (AICTE)).pptx
vectors.(join ALL INDIA POLYTECHNIC (AICTE)).pptx
 
Lab exam 5_5_15
Lab exam 5_5_15Lab exam 5_5_15
Lab exam 5_5_15
 
12.9 Program Online shopping cart (continued) (C++)This program e.pdf
12.9 Program Online shopping cart (continued) (C++)This program e.pdf12.9 Program Online shopping cart (continued) (C++)This program e.pdf
12.9 Program Online shopping cart (continued) (C++)This program e.pdf
 
Visual basic bt0082
Visual basic  bt0082Visual basic  bt0082
Visual basic bt0082
 
Assignment in java
Assignment in javaAssignment in java
Assignment in java
 
© 2014 Laureate Education, Inc. Page 1 of 4 Retail Trans.docx
© 2014 Laureate Education, Inc.   Page 1 of 4 Retail Trans.docx© 2014 Laureate Education, Inc.   Page 1 of 4 Retail Trans.docx
© 2014 Laureate Education, Inc. Page 1 of 4 Retail Trans.docx
 
java I am trying to run my code but it is not letting me .pdf
java    I am trying to run my code but it is not letting me .pdfjava    I am trying to run my code but it is not letting me .pdf
java I am trying to run my code but it is not letting me .pdf
 
Functional DDD
Functional DDDFunctional DDD
Functional DDD
 
19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.ppt19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.ppt
 
Heap sort - Arafath Islam Sezan.pptx
Heap sort - Arafath Islam Sezan.pptxHeap sort - Arafath Islam Sezan.pptx
Heap sort - Arafath Islam Sezan.pptx
 
Array list(1)
Array list(1)Array list(1)
Array list(1)
 
Write ItemList.h and ItemList.cItemList is used to store a list .pdf
Write ItemList.h and ItemList.cItemList is used to store a list .pdfWrite ItemList.h and ItemList.cItemList is used to store a list .pdf
Write ItemList.h and ItemList.cItemList is used to store a list .pdf
 

Plus de adcrates2010

Determine si las afirmaciones pertenecen a una poblacin o a.pdf
Determine si las afirmaciones pertenecen a una poblacin o a.pdfDetermine si las afirmaciones pertenecen a una poblacin o a.pdf
Determine si las afirmaciones pertenecen a una poblacin o a.pdfadcrates2010
 
Determine Gales income tax each year from through assumin.pdf
Determine Gales income tax each year from through  assumin.pdfDetermine Gales income tax each year from through  assumin.pdf
Determine Gales income tax each year from through assumin.pdfadcrates2010
 
Depo Ynetim Sistemi depo ynetim sistemi kontrol etmek ii.pdf
Depo Ynetim Sistemi depo ynetim sistemi kontrol etmek ii.pdfDepo Ynetim Sistemi depo ynetim sistemi kontrol etmek ii.pdf
Depo Ynetim Sistemi depo ynetim sistemi kontrol etmek ii.pdfadcrates2010
 
Despus de leer el artculo responda las preguntas que sigu.pdf
Despus de leer el artculo responda las preguntas que sigu.pdfDespus de leer el artculo responda las preguntas que sigu.pdf
Despus de leer el artculo responda las preguntas que sigu.pdfadcrates2010
 
Description of the project Purpose To implement a simple au.pdf
Description of the project Purpose To implement a simple au.pdfDescription of the project Purpose To implement a simple au.pdf
Description of the project Purpose To implement a simple au.pdfadcrates2010
 
Design Patterns Java An Internet Service Provider ISP no.pdf
Design Patterns Java  An Internet Service Provider ISP no.pdfDesign Patterns Java  An Internet Service Provider ISP no.pdf
Design Patterns Java An Internet Service Provider ISP no.pdfadcrates2010
 
Describe what you think the company is doing right in regard.pdf
Describe what you think the company is doing right in regard.pdfDescribe what you think the company is doing right in regard.pdf
Describe what you think the company is doing right in regard.pdfadcrates2010
 
Describe what is meant by a graded river At steady state i.pdf
Describe what is meant by a graded river At steady state i.pdfDescribe what is meant by a graded river At steady state i.pdf
Describe what is meant by a graded river At steady state i.pdfadcrates2010
 
Describe the properties of a neutron star Density Neutro.pdf
Describe the properties of a neutron star  Density Neutro.pdfDescribe the properties of a neutron star  Density Neutro.pdf
Describe the properties of a neutron star Density Neutro.pdfadcrates2010
 
Design a project document for a Ddos attack detection projec.pdf
Design a project document for a Ddos attack detection projec.pdfDesign a project document for a Ddos attack detection projec.pdf
Design a project document for a Ddos attack detection projec.pdfadcrates2010
 
Describe what a balance sheet tells about a business in your.pdf
Describe what a balance sheet tells about a business in your.pdfDescribe what a balance sheet tells about a business in your.pdf
Describe what a balance sheet tells about a business in your.pdfadcrates2010
 
Design a Data Base many to many each house can have many .pdf
Design a Data Base many to many each house can have many .pdfDesign a Data Base many to many each house can have many .pdf
Design a Data Base many to many each house can have many .pdfadcrates2010
 
Desea revisar las dependencias de tareas en su programa ante.pdf
Desea revisar las dependencias de tareas en su programa ante.pdfDesea revisar las dependencias de tareas en su programa ante.pdf
Desea revisar las dependencias de tareas en su programa ante.pdfadcrates2010
 
Desde una perspectiva muy bsica la respiracincombustin .pdf
Desde una perspectiva muy bsica la respiracincombustin .pdfDesde una perspectiva muy bsica la respiracincombustin .pdf
Desde una perspectiva muy bsica la respiracincombustin .pdfadcrates2010
 
Describe how Nanoporebased nucleic acid sequencing takes ad.pdf
Describe how Nanoporebased nucleic acid sequencing takes ad.pdfDescribe how Nanoporebased nucleic acid sequencing takes ad.pdf
Describe how Nanoporebased nucleic acid sequencing takes ad.pdfadcrates2010
 
Description Find a cybersecurity incident that has recently .pdf
Description Find a cybersecurity incident that has recently .pdfDescription Find a cybersecurity incident that has recently .pdf
Description Find a cybersecurity incident that has recently .pdfadcrates2010
 
Describe a time when you were able to achieve something that.pdf
Describe a time when you were able to achieve something that.pdfDescribe a time when you were able to achieve something that.pdf
Describe a time when you were able to achieve something that.pdfadcrates2010
 
Describe a leader with whom you are familiar You can choose.pdf
Describe a leader with whom you are familiar You can choose.pdfDescribe a leader with whom you are familiar You can choose.pdf
Describe a leader with whom you are familiar You can choose.pdfadcrates2010
 
Description 1 Imagine a young person recently graduated fr.pdf
Description 1 Imagine a young person recently graduated fr.pdfDescription 1 Imagine a young person recently graduated fr.pdf
Description 1 Imagine a young person recently graduated fr.pdfadcrates2010
 
Describe the two escalator model that economists Case and .pdf
Describe the two escalator model that economists Case and .pdfDescribe the two escalator model that economists Case and .pdf
Describe the two escalator model that economists Case and .pdfadcrates2010
 

Plus de adcrates2010 (20)

Determine si las afirmaciones pertenecen a una poblacin o a.pdf
Determine si las afirmaciones pertenecen a una poblacin o a.pdfDetermine si las afirmaciones pertenecen a una poblacin o a.pdf
Determine si las afirmaciones pertenecen a una poblacin o a.pdf
 
Determine Gales income tax each year from through assumin.pdf
Determine Gales income tax each year from through  assumin.pdfDetermine Gales income tax each year from through  assumin.pdf
Determine Gales income tax each year from through assumin.pdf
 
Depo Ynetim Sistemi depo ynetim sistemi kontrol etmek ii.pdf
Depo Ynetim Sistemi depo ynetim sistemi kontrol etmek ii.pdfDepo Ynetim Sistemi depo ynetim sistemi kontrol etmek ii.pdf
Depo Ynetim Sistemi depo ynetim sistemi kontrol etmek ii.pdf
 
Despus de leer el artculo responda las preguntas que sigu.pdf
Despus de leer el artculo responda las preguntas que sigu.pdfDespus de leer el artculo responda las preguntas que sigu.pdf
Despus de leer el artculo responda las preguntas que sigu.pdf
 
Description of the project Purpose To implement a simple au.pdf
Description of the project Purpose To implement a simple au.pdfDescription of the project Purpose To implement a simple au.pdf
Description of the project Purpose To implement a simple au.pdf
 
Design Patterns Java An Internet Service Provider ISP no.pdf
Design Patterns Java  An Internet Service Provider ISP no.pdfDesign Patterns Java  An Internet Service Provider ISP no.pdf
Design Patterns Java An Internet Service Provider ISP no.pdf
 
Describe what you think the company is doing right in regard.pdf
Describe what you think the company is doing right in regard.pdfDescribe what you think the company is doing right in regard.pdf
Describe what you think the company is doing right in regard.pdf
 
Describe what is meant by a graded river At steady state i.pdf
Describe what is meant by a graded river At steady state i.pdfDescribe what is meant by a graded river At steady state i.pdf
Describe what is meant by a graded river At steady state i.pdf
 
Describe the properties of a neutron star Density Neutro.pdf
Describe the properties of a neutron star  Density Neutro.pdfDescribe the properties of a neutron star  Density Neutro.pdf
Describe the properties of a neutron star Density Neutro.pdf
 
Design a project document for a Ddos attack detection projec.pdf
Design a project document for a Ddos attack detection projec.pdfDesign a project document for a Ddos attack detection projec.pdf
Design a project document for a Ddos attack detection projec.pdf
 
Describe what a balance sheet tells about a business in your.pdf
Describe what a balance sheet tells about a business in your.pdfDescribe what a balance sheet tells about a business in your.pdf
Describe what a balance sheet tells about a business in your.pdf
 
Design a Data Base many to many each house can have many .pdf
Design a Data Base many to many each house can have many .pdfDesign a Data Base many to many each house can have many .pdf
Design a Data Base many to many each house can have many .pdf
 
Desea revisar las dependencias de tareas en su programa ante.pdf
Desea revisar las dependencias de tareas en su programa ante.pdfDesea revisar las dependencias de tareas en su programa ante.pdf
Desea revisar las dependencias de tareas en su programa ante.pdf
 
Desde una perspectiva muy bsica la respiracincombustin .pdf
Desde una perspectiva muy bsica la respiracincombustin .pdfDesde una perspectiva muy bsica la respiracincombustin .pdf
Desde una perspectiva muy bsica la respiracincombustin .pdf
 
Describe how Nanoporebased nucleic acid sequencing takes ad.pdf
Describe how Nanoporebased nucleic acid sequencing takes ad.pdfDescribe how Nanoporebased nucleic acid sequencing takes ad.pdf
Describe how Nanoporebased nucleic acid sequencing takes ad.pdf
 
Description Find a cybersecurity incident that has recently .pdf
Description Find a cybersecurity incident that has recently .pdfDescription Find a cybersecurity incident that has recently .pdf
Description Find a cybersecurity incident that has recently .pdf
 
Describe a time when you were able to achieve something that.pdf
Describe a time when you were able to achieve something that.pdfDescribe a time when you were able to achieve something that.pdf
Describe a time when you were able to achieve something that.pdf
 
Describe a leader with whom you are familiar You can choose.pdf
Describe a leader with whom you are familiar You can choose.pdfDescribe a leader with whom you are familiar You can choose.pdf
Describe a leader with whom you are familiar You can choose.pdf
 
Description 1 Imagine a young person recently graduated fr.pdf
Description 1 Imagine a young person recently graduated fr.pdfDescription 1 Imagine a young person recently graduated fr.pdf
Description 1 Imagine a young person recently graduated fr.pdf
 
Describe the two escalator model that economists Case and .pdf
Describe the two escalator model that economists Case and .pdfDescribe the two escalator model that economists Case and .pdf
Describe the two escalator model that economists Case and .pdf
 

Dernier

Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Developmentchesterberbo7
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17Celine George
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...DhatriParmar
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvRicaMaeCastro1
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleCeline George
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 

Dernier (20)

prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Development
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP Module
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 

Design a class named Item by compiling a UML diagram for the.pdf

  • 1. Design a class named Item by compiling a UML diagram for the class. Item -name: String -numInStock: int -costPrice: double -sellingPrice: double +Item() +Item(name: String, costPrice:double) +getName(): String +getNumInStock(): int +getCostPrice(): double +setNumInStock(numStock: int): void +setSellingPrice(percProfit: double): void +calcStockValue(): double +sellItems(numToSell:int) The class should contain: A string data field named name for the items name. An int data field named numInStock that stores the number of the item in stock. A double data field named costPrice that stores the price that the item was purchased for. A double data field named sellingPrice that stores the price that the item must be sold for. Two overloaded constructors: A default (no-argument) constructor that creates a default account (receives no values) A constructor with two parameters that receives the name and cost price of the item. Assign the parameter values to the relevant instance fields. Assign the value of 0 to the numInStock instance field and the value of the costPrice to the sellingPrice instance field. Accessor methods for all the instance fields. Two mutator methods: setNumInStock() that receives a value as the number of stock. Assign the value to the relevant instance field. setSellingPrice(percProfit:double) that receives the percentage profit that should be made on the cost price of the item. Calculate and assign the selling price to the sellingPrice instance field. Use the following information to do the calculation: sellingPrice = costPrice + (costPrice * percProfit/100) A method named sellItems() that receives the number of items to be sold. If the number received is greater than the number of items in stock, return the value -1 which indicates that no items were sold. If there is enough stock, subtract the number received from the number in stock and return the value of 0. A method named calcStockValue() that calculates and returns the stock value of items using the costPrice multiplied by the and the number of items in stock. toString() method to compiled and return an output string in the following format: Name of item: xxxxxx Cost price: R xxxxx.xx
  • 2. Number in stock: xx Selling price: R xxxxx.xx Do the following: Write code for the Item class as described in the section above. Write a test program named testItem that allows the user to enter the name of an item and the cost price of the item. Instantiates (creates) an Item object calling the parameterised constructor with the name and cost price of the item as arguments. Call the setNumInStock() method to set the number of items in stock to the value 10 Call the setSellingPrice() method using the value of 50 as the % profit to be made on the cost price of the item. Use the toString() method to display the information of the Item object. Call the calcStockValue() and display the value as follows: Value of items in stock: R xxxxxx.xx Selling items: Display the heading Selling items Use while loop to allow the user to how many items must be sold. While there are items in stock and the input of the user is more than 0 do the following: Call the sellItems() method to sell the items. If the method returns the value of -1, display a message indicating that there is not enough stock. Also display the number of items in stock by calling the getNumInStock() method. If there is enough stock, display a message indicating that the items were sold. Also display the number of items in stock (after the sale) by calling the getNumInStock() method. Example of output if the input is Bag as the name of the item and R150.00 as the cost price: Name of item: Bag Cost price: R 150.00 Number in stock: 10 Selling price: R 225.00 Value of items in stock: R 1500.00 Selling items: Enter the number of items to sell (0 to quit): 4 Number of items sold: 4 Number of items in stock: 6 Enter the number of items to sell (0 to quit): 8 Not enough stock Number of items in stock: 6 Enter the number of items to sell (0 to quit): 6 Number of items sold: 6 Number of items in stock: 0
  • 3. Done. Item -name: String -numInStock: int -costPrice: double -sellingPrice: double +Item() +Item(name: String, costPrice:double) +getName(): String +getNumInStock(): int +getCostPrice(): double +setNumInStock(numStock: int): void +setSellingPrice(percProfit: double): void +calcStockValue(): double +sellItems(numToSell:int)