Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

Java language, please solve the 4 parts sir, thank u alot

**Lab Objectives:**
- To define arrays of objects.
- To pass objects to methods.

---

**Task:**

You will use the implementation of the Item class from Lab-5.

**Implement the following class named Item with the following UML diagram:**

---

### UML Diagram for Item Class

**Attributes:**
- `+ name: String`
- `- reviews: String[]`
- `- priceWithoutTax: double`
- `- salesTax: double = 0.16`

**Methods:**
- `+ Item()`
- `+ Item(name: String, priceWithoutTax: double)`
- `+ Item(item: Item)`
- `+ getReviews(): String[]`
- `+ addReview(): void`
- `+ getPriceWithoutTax(): double`
- `+ setPriceWithoutTax(priceWithoutTax: double): void`
- `+ getSalesTax(): double`
- `+ setSalesTax(salesTax: double): void`
- `+ getPriceWithTax(): double`
- `+ printReviews(): void`
- `+ searchReviews(): void`

---

**Instructions:**

- Add the `Item(Item item)` constructor which initializes the data fields `name` and `priceWithoutTax` with values of the corresponding data fields of the passed object `item`.

**In Your Main Class:**

1. Implement a method named `createListOfItems` which asks the user about the number of items to be created and returns an array that consists of the passed number of items created using the no-arg constructor.

2. Implement a method named `printItems` which takes an array of items and prints the items’ details to the console as a table as follows:

   ```
   Item name    Price without tax    Price with tax
   .
   .
   ```

3. Implement a method named `searchItem` which takes an array of items and a `String` which represents the name of the item to search for. If an item with the passed name is found, it must be returned. If no item with the passed name is found, the method must return `null`.
expand button
Transcribed Image Text:**Lab Objectives:** - To define arrays of objects. - To pass objects to methods. --- **Task:** You will use the implementation of the Item class from Lab-5. **Implement the following class named Item with the following UML diagram:** --- ### UML Diagram for Item Class **Attributes:** - `+ name: String` - `- reviews: String[]` - `- priceWithoutTax: double` - `- salesTax: double = 0.16` **Methods:** - `+ Item()` - `+ Item(name: String, priceWithoutTax: double)` - `+ Item(item: Item)` - `+ getReviews(): String[]` - `+ addReview(): void` - `+ getPriceWithoutTax(): double` - `+ setPriceWithoutTax(priceWithoutTax: double): void` - `+ getSalesTax(): double` - `+ setSalesTax(salesTax: double): void` - `+ getPriceWithTax(): double` - `+ printReviews(): void` - `+ searchReviews(): void` --- **Instructions:** - Add the `Item(Item item)` constructor which initializes the data fields `name` and `priceWithoutTax` with values of the corresponding data fields of the passed object `item`. **In Your Main Class:** 1. Implement a method named `createListOfItems` which asks the user about the number of items to be created and returns an array that consists of the passed number of items created using the no-arg constructor. 2. Implement a method named `printItems` which takes an array of items and prints the items’ details to the console as a table as follows: ``` Item name Price without tax Price with tax . . ``` 3. Implement a method named `searchItem` which takes an array of items and a `String` which represents the name of the item to search for. If an item with the passed name is found, it must be returned. If no item with the passed name is found, the method must return `null`.
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY