[SOLVED] CSIT121 Object-Oriented Design And Programming JavaLab4

34.99 $

Programming resource
Digital learning resource
Category:
Practical programming resource
Suitable for guided study and reference
Tutor guidance available when needed

Description

5/5 - (1 vote)

 OBJECTIVES:

 Following completion of this task, students should be able to:

  • Write Java applications using object and files.

 Question 1

In this lab task you are required to write a Java application that reads and writes objects from/to a file.

Step 1

Declare and implement a class named InventoryItem based on the class diagram given below:

 

InventoryItem
 

–  serialNum : int

–  description : String

–  costPrice : double

–  sellingPrice : double

–  quantityInHand : int

 

 

+ InventoryItem()

+ setSerialNum(int) : void

+ setDescription(String) : void

+ setCostPrice (double) : void

+ setSellingPrice (double) : void

+ setQuantityInHand(int) : void

+ getSerialNum() : int

+ getDescription() : String

+ getCostPrice () : double

+ getSellingPrice () : double

+ getQuantityInHand() : int

+ getTotalRevenue() : double

Step 2

Write a Java application that performs the following operations:

  • Prompt the user to enter information for several InventoryItem objects that are stored in an ArrayList.
  • Save all the InventoryItem objects in a simple csv text file (i.e. comma-separated values format).
  • Read all InventoryItem objects from the file and display them in tabular format including the projected total profit for each item and overall inventory as well.

 

The following shows an example simple csv text file format. Each line represent an object’s data.

 

12534,office chairs,75.0,100.0,25

17654,coffee table,350.0,700.0,5

18834,dining table,1500.0,2750.0,10

14214,sofa set,2000.0,3500.0,7

 

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.