0% found this document useful (0 votes)
5 views

Array of ItemType objects

The document outlines the creation of an array of ItemType objects to enhance an application with search functionality. It specifies the structure of the ItemType class, including its attributes and methods for adding, searching, and displaying items. Additionally, it describes a Main driver class for user interaction and provides input/output formatting requirements with sample scenarios.

Uploaded by

asmi10266
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Array of ItemType objects

The document outlines the creation of an array of ItemType objects to enhance an application with search functionality. It specifies the structure of the ItemType class, including its attributes and methods for adding, searching, and displaying items. Additionally, it describes a Main driver class for user interaction and provides input/output formatting requirements with sample scenarios.

Uploaded by

asmi10266
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Array of ItemType objects

Kudos, your application is progressing really good but its time to add some really
cool features to it. Until now you have created single objects for each class, now
there's a need to create an array of objects for a class to enable the search
feature. Create an array of ItemType objects. Also, add a provision for adding a
new ItemType object to the array of ItemType objects. Create an interactive console
to get input from the user for performing different actions on the array.

Strictly adhere to the Object-Oriented specifications given in the problem


statement. All class names, attribute names and method names should be the same as
specified in the problem statement.

Create a class named ItemType with the following private attributes.

Attributes Datatype
name String
deposit Double
costPerDay Double
Include appropriate getters and setters for the class.
Include appropriate constructor(s) for the class.

Create a class named ItemTypeBO class and include the following methods.

Method Description
public void add(ItemType object ,ItemType[] itemTypeArray,Integer index) This
method accepts an array of ItemType objects, an ItemType object and the
index at which the object is to be added.
The method appends the object to the array of ItemType objects at the specified
index and prints
"New item added successfully"
public void search(String search, ItemType[] itemTypeArray)This method accepts the
search term and the array of ItemType objects as input.
It displays the details of the ItemType if matched. else prints "Searched Item Type
not found"
public void display(ItemType[] itemTypeArray) This method accepts an array of
ItemType objects as arguments.
It displays the details one by one.

Create a driver class called Main. In the Main method, obtain input from the user
and call the ItemTypeBO functions appropriately.

Input and Output format:


The size of the itemType Array should be 10. (1<=n>=10).
Display the value of the deposit amount correct to 1 decimal place.
The search statement "Enter the Name of the item to be searched" should be in the
Main method.
Refer to sample Input and Output for formatting specifications.

Sample Input and Output 1:


[All text in bold corresponds to the input and rest corresponds to output]

Enter the Number of Item Type


3
Enter the Item Type 1 Name
Electronics
Enter the Deposit Amount
2500
Enter the Cost per day
150
New item added successfully
Enter the Item Type 2 Name
Chemicals
Enter the Deposit Amount
500
Enter the Cost per day
50
New item added successfully
Enter the Item Type 3 Name
Construction
Enter the Deposit Amount
2000
Enter the Cost per day
500
New item added successfully
Item Type Number 1:
Name:Electronics
Deposit Amount:2500.0
Cost Per Day:150.0
Item Type Number 2:
Name:Chemicals
Deposit Amount:500.0
Cost Per Day:50.0
Item Type Number 3:
Name:Construction
Deposit Amount:2000.0
Cost Per Day:500.0
Enter the Name of the item to be searched
Construction
Searched Item Type is:
Name:Construction
Deposit Amount:2000.0
Cost Per Day:500.0

Sample Input and Output 2:


Enter the Number of Item Type
2
Enter the Item Type 1 Name
Electricals
Enter the Deposit Amount
2000
Enter the Cost per day
200
New item added successfully
Enter the Item Type 2 Name
Mechanic kit
Enter the Deposit Amount
3000
Enter the Cost per day
250
New item added successfully
Item Type Number 1:
Name:Electricals
Deposit Amount:2000.0
Cost Per Day:200.0
Item Type Number 2:
Name:Mechanic kit
Deposit Amount:3000.0
Cost Per Day:250.0
Enter the Name of the item to be searched
Electronics
Searched Item Type not found

You might also like