Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Oop Assignment 2

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

 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 Roll No.: 3297

Student Name: M. Ayyaz Khan Roll No.: 3293

Student Name: M. Haseeb Ahmad Roll No.: 3290

Student Name: Mehmood ahmed Roll No.: 3294

Student Name: Rafia Asif Roll No.: 3322

Student Name: Fatima Amin Roll No.: 3307

Submission Date: 25 Mar 2024

 ASSESSOR USE ONLY:

Result: Assignment 2 o Satisfactory o Not Satisfactory

Feedback: Feedback is given to the student on each Yes / No


Assessment task & final outcome of the unit

Assessor’s
Feedback:

Assessor’s Date:
Signature:
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.
 Static Variables and Functions to keep a record of total products:
o totalProducts is a static variable that keeps track of the total number of products in the
inventory system.
o getTotalProducts() is a static method that retrieves the total number of products recorded.
o Source code of the given Scenario:
o Product Class:
o

o Main Class:
o

o Output of the given Scenario:


o

You might also like