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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
With refer to the below code write the code for this 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.

It is the code of part one only and only write answer for me with respect to this code in the pic u can see the test code for it as well .
 
import java.util.Scanner;

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());
  }
}
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
}
}
}
}
break;
case 2:
laptop.itemSell();
System.out.println(x:
System.out.println();
System.out.println(x: "Printing item stock information:");
laptop.getItemDetails();
System.out.println();
break;
case 0:
break;
default:
"Sold 1 item");
System.out.println(x: "Invalid option");
Transcribed Image Text:31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 } } } } break; case 2: laptop.itemSell(); System.out.println(x: System.out.println(); System.out.println(x: "Printing item stock information:"); laptop.getItemDetails(); System.out.println(); break; case 0: break; default: "Sold 1 item"); System.out.println(x: "Invalid option");
public class StockedItem {
Run | Debug
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
ItemInStock laptop = new ItemInStock (itemCode: "C15", quantity: 5, itemPrice: 180);
System.out.println(x: "Creating a stock with 5 units Laptops i-5 11g 8gb 1tb, price R.O 180 per item, and item code C15");
System.out.println();
System.out.println(x: "Laptops item stock information:");
laptop.getItemDetails();
System.out.println();
int option = -1;
while (option != 0) {
System.out.println(x: "What do you want to do?");
System.out.println(x: "1. Add items");
System.out.println(x: "2. Sell items");
System.out.println(x: "0. Exit");
option = scanner.nextInt ();
switch (option) {
case 1:
laptop.addItem();
System.out.println(x: "Adding 1 more item");
System.out.println();
System.out.println(x: "Printing item stock information:");
laptop.getItemDetails();
System.out.println();
Transcribed Image Text:public class StockedItem { Run | Debug public static void main(String[] args) { Scanner scanner = new Scanner(System.in); ItemInStock laptop = new ItemInStock (itemCode: "C15", quantity: 5, itemPrice: 180); System.out.println(x: "Creating a stock with 5 units Laptops i-5 11g 8gb 1tb, price R.O 180 per item, and item code C15"); System.out.println(); System.out.println(x: "Laptops item stock information:"); laptop.getItemDetails(); System.out.println(); int option = -1; while (option != 0) { System.out.println(x: "What do you want to do?"); System.out.println(x: "1. Add items"); System.out.println(x: "2. Sell items"); System.out.println(x: "0. Exit"); option = scanner.nextInt (); switch (option) { case 1: laptop.addItem(); System.out.println(x: "Adding 1 more item"); System.out.println(); System.out.println(x: "Printing item stock information:"); laptop.getItemDetails(); System.out.println();
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education