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

The solution to an assignment in object oriented programming (oop) for a product inventory system. The solution includes defining a product class with attributes and constructors, implementing methods for updating stock, displaying product details, calculating inventory value, and tracking total products. The solution also includes static variables and functions to keep a record of total products.

Typology: Assignments

2023/2024

Uploaded on 03/23/2024

mirza-ammar
mirza-ammar 🇵🇰

2 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

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: