0% found this document useful (0 votes)
28 views2 pages

Pra Ori

The document outlines the design of a system for managing manufacturers and their products, including a Manufacturer class with attributes and methods for calculating average product prices and finding manufacturers by product name. It specifies the requirements for two non-static methods in a ManufacturerService class, including error handling for non-existent manufacturers and products. Additionally, it provides sample input and output to guide implementation and testing.

Uploaded by

harshrastogi2020
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views2 pages

Pra Ori

The document outlines the design of a system for managing manufacturers and their products, including a Manufacturer class with attributes and methods for calculating average product prices and finding manufacturers by product name. It specifies the requirements for two non-static methods in a ManufacturerService class, including error handling for non-existent manufacturers and products. Additionally, it provides sample input and output to guide implementation and testing.

Uploaded by

harshrastogi2020
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

Electronics Manufacturer -Modified

ANY MEANS OF ISTENDED PLAGIARISM WHILE ATTEMPTING THIS QUESTION IS LIABLE TO


HIGHEST POSSIBLE STRICT HR ACTIONS AS IT IS VIOLATION IF INTEGRITY. HENCE, REFRAIN
FROM ANY SUCH MEANS AND ATTEMPT THIS QUESTION AS PER YOUR EXPERTISE ONLY.

You are tasked with designing a system to manage manufacturers and their products.
The system involves the following:

Class Manufacturer:

Attributes:

- manufacturerld (int)

- manufacturer Name (String)

- noOfProducts (int)

- products (List of Strings): A list of product names.

prices (List of Integers): A list of prices corresponding to the products.

Create getters, setters and constructor for the above Manufacturer class.

The two non-static methods described below, should be created in a


ManufacturerService Class:
Task 1: Find the Average Price of Products by Manufacturer

Create a non-static method that calculates and returns the average price of all
products for a s. ified manufacturer.

- The method should accept an integer parameter, 'manufacturerld'.

- It should fetch all products associated with the given 'manufacturerld' and
calculate the average price.

- If there are no products associated with the given 'manufacturerld', or if the


manufacturer does not exist, the method should print "Manufacturer Not Found" and
return 'null' (or handle as needed).

Task 2: Find Manufacturers by Product Name

Create a non-static method that retrieves a list of manufacturers who produce a


specific product.

- The method should accept a string parameter, 'productName'.

- It should search for all manufacturers that produce the product with the given
'productName' and return a list of manufacturer names.

- If no manufacturers are found for the given 'productName', the method should
throw a custom exception called 'ProductNotFoundException', which includes the
message "Product Not Found".
Note:

-Write the code for accepting inputs, printing outputs and calling the non-static
methods in the main method from the Manufacturer Tester class.
-You can refer to the sample input/output below to verify your solution.

-Don't use any static test or formatting for printing the result. Just invoke the
methods and prime result.

-All comparisons should be case-insensitive.

Sample Input 1:

2
2001
Dell
2
Laptop
800
Monitor
300
2002
HP
2
Printer
150
Laptop
750
2001
Laptop

Sample Output 1:
550.0
Dell
HP

Sample Input 2:

2
5001
Tesla
2
Model S
80000
Model X
90000
5002
Ford
2
Mustang
40000
F-150
45000
6000
Cybertruck

Sample Output 2:
Manufacturer Not Found
Product Not Found

You might also like