Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am begging you to refer to my part one code to solve this question I will write my part one code here check it

I am begging you to refer to my part one code to solve this question I will write my part one code here check it then read part 2 which is my issue now then answer part two. already I lost 4 monthly questions in Chegg because no one did not attention to my part one code but they related together pls pls refer to my part one and uses the same name so my code comes without thank you.

public class ItemInStock {

private String itemCode;

private String itemName;

private String itemDescription;

private int quantity;

private double itemPrice;

private String item_category;

public ItemInStock(String itemCode, int quantity, double itemPrice) {

this.itemCode = itemCode;

this.quantity = quantity;

this.itemPrice = itemPrice;

}

public String getItemCode() {

return this.itemCode;

}

public void setItemCode(String itemCode) {

this.itemCode = itemCode;

}

public String getItemName() {

return this.itemName;

}

public void setItemName(String itemName) {

this.itemName = itemName;

}

public String getItemDescription() {

return this.itemDescription;

}

public void setItemDescription(String itemDescription) {

this.itemDescription = itemDescription;

}

public int getQuantity() {

return this.quantity;

}

public void setQuantity(int quantity) {

this.quantity = quantity;

}

public double getItemPrice() {

return this.itemPrice;

}

public void setItemPrice(double itemPrice) {

this.itemPrice = itemPrice;

}

public String getItem_category() {

return item_category ;

}

public void setItem_category(String item_category) {

this.item_category = item_category;

}

public void addItem() {

if (this.quantity + 1 > 25) {

System.out.println("The error: Item stock must not exceed 25 items");

} else {

this.quantity++;

}

}

public void itemSell() {

Scanner scanner = new Scanner(System.in);

System.out.print("Enter the quantity of items to sell: ");

int sellQuantity = scanner.nextInt();

if (sellQuantity > this.quantity) {

System.out.println("Error: Not enough items in stock");

} else {

this.quantity -= sellQuantity;

}

}

public double taxOnItem() {

return this.itemPrice * 0.05;

}

public double getItemPriceWithTax() {

return this.itemPrice + this.taxOnItem();

}

public void getItemDetails() {

System.out.println("Item Category: " + this.getItem_category());

System.out.println("Item Name: " + this.getItemName());

System.out.println("Description: " + this.getItemDescription());

System.out.println("StockCode: " + this.getItemCode());

System.out.println("Price Without Tax: R. O " + this.getItemPrice());

System.out.println("Price With Tax: R.O " + this.getItemPriceWithTax());

System.out.println("Total quantity in store: " + this.getQuantity());

}

}

My Qustion :

In this part of the course work, you are required to design and implement a class called HP_Laptop with instance variables specific to this type of items, a constructor with parameters which initialises class data members and invokes the Item_in_Stock constructor when it is invoked using inheritance concept in java and initialises data members of Item_in_stock class as well. This class should be designed and implemented in a way that it overrides getItemCategory() that returns the category of the item, getItemName() that returns HP_Laptop and getItemDescription() that returns HP_I5_11G_8GB_1TB . The Class should also override the get_item_details() method to display the complete details of an item.

Task 2.1. Re-draw UML class diagram which was drawn in part 1 of the course work with this new class HP_Laptop. Relationships should also be represented.

Task 2.2. Implement a class called Item_check with a main method to test HP_Laptop class by defining object of the class and invoking methods.

Testing is an integral part of development. Write suitable test cases in the given format below for your classes.

Test Case

Purpose

Expected result

OUTPUT:

Refer to output in part I, item category, item name and item description should be according to the Items.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Iv Special Issue On Database Systems For Biomedical Applications Lncs 6990

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Christian Bohm ,Johann Eder ,Claudia Plant

2011th Edition

3642237398, 978-3642237393

More Books

Students also viewed these Databases questions