Docsity

Object Oriented Programming Assignment Solution: Product Inventory System, Assignments of Java Programming

Toggle sidebar
bg1
STUDENT DETAILS / DECLARATION:
Course Name: Bachelor of Science in Computer Science (BSCS)
Unit / Subject Name: Object Oriented Programming
Trainer’s Name: Ms. Shumaila Qayyum Assignment No: 2
Student Name: Ammar Azmat Student ID/Roll No.: 3297
Student Name: M. Ayyaz Khan Student ID/Roll No.: 3293
Submission Date:
ASSESSOR USE ONLY:
Result: Assignment 2 o Satisfactory o Not Satisfactory
Feedback: Feedback is given to the student on each
Assessment task & final outcome of the unit
Yes / No
Assessor’s
Feedback:
Assessor’s
Signature:
Date:
--------------------------------------------------------------------------------------
ASSESSMENT FIRST SUBMISSION/RE-SUBMISSION RECEIPT: It is student’s responsibility to keep the
assessment submission receipt as a proof of submission of assessment tasks.
Student Names: Ammar Azmat & M. Ayyaz Khan Student ID
/Roll No.:
3297 & 3293
Unit / Subject Code: Object Oriented Programming Assignment No.: 2
Trainer Name: Ms. Shumaila Qayyum Date:
Signature:
Assessor’s
Signature:
Date:
pf3
pf4
pf5

Partial preview of the text

Download Object Oriented Programming Assignment Solution: Product Inventory System and more Assignments Java Programming in PDF only on Docsity!

 STUDENT DETAILS / DECLARATION:

Course Name: Bachelor of Science in Computer Science (BSCS) Unit / Subject Name: Object Oriented Programming Trainer’s Name: Ms. Shumaila Qayyum Assignment No: 2 Student Name: Ammar Azmat Student ID/Roll No.: 3297 Student Name: M. Ayyaz Khan Student ID/Roll No.: 3293 Submission Date:  ASSESSOR USE ONLY: Result: Assignment 2 o Satisfactory o Not Satisfactory Feedback: Feedback is given to the student on each Assessment task & final outcome of the unit Yes / No Assessor’s Feedback: Assessor’s Signature: Date:

 ASSESSMENT FIRST SUBMISSION/RE-SUBMISSION RECEIPT: It is student’s responsibility to keep the assessment submission receipt as a proof of submission of assessment tasks. Student Names: Ammar Azmat & M. Ayyaz Khan Student ID /Roll No.: 3297 & 3293 Unit / Subject Code: Object Oriented Programming Assignment No.: 2 Trainer Name: Ms. Shumaila Qayyum Date: Signature: Assessor’s Signature: Date:

TASK: Scenario: ā€œProduct Inventory Systemā€

You are developing a simple Product Inventory System for a retail store. Each product has a unique product code, a name, a price, and a quantity in stock. The system should be able to perform operations like updating the stock quantity, displaying product details, and calculating the total value of the inventory. Additionally, there should be a mechanism to track the total number of products in the inventory.

1. Define a Product class with the following attributes: productCode, productName, price, and quantityInStock. 2. Implement constructors with overloading properties for the Product class. 3. Implement multiple methods with overloading for the Product class. Implement Static Variables and Functions to keep record of total products.

ANSWER:

ļ‚· Attributes of the product class: o productCode o productName o price o quantityInStock ļ‚· Constructors with overloading properties for the Product class: There are two constructors provided: o One constructor accepts parameters for all attributes (productCode, productName, price, quantityInStock). o Another constructor accepts parameters for all attributes except quantityInStock, initializing it to 0 by default. ļ‚· Multiple methods with overloading for the Product class: o updateStock(int quantity): Updates the stock quantity of the product. o displayProductDetails(): Displays the details of the product including productCode, productName, price, and quantityInStock. o calculateInventoryValue(): Calculates and returns the total value of the inventory for the product (price * quantityInStock). o getTotalProducts(): Static method that returns the total number of products recorded. o Getter methods for individual attributes (getProductCode(), getProductName(), getPrice(), getQuantityInStock()) : Provide access to individual attributes of the product.

Output of the given Scenario: