Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider that an e-commerce company wants to keep track of all their products and want to use linked list. Follow the instructions to create a

Consider that an e-commerce company wants to keep track of all their products and want to use linked list. Follow the instructions to create a java program for that company.

  1. Design a java interface called IDedObject which has following abstract functions.

int getID() //Returns the ID of the object

void printID() //Prints the details of the ID

  1. Design a java class Product that implements IDedObject interface and has the following class variables:

int productID

String productName

String supplierName

Implement suitable constructors, a printID function that prints all the variable values in separate lines and getID() function that returns the productID. Add any access and other functions necessary.

{Note all your data should be private and methods public inside the class)

  1. Design a generic singly linked list java class (Give an appropriate name) to hold objects of the generic type . This AnyType should extend IDedObject. You have to design your own class that does not use any other Java collection ApI. The linked list class must implement following member functions:

A constructor which generates an empty list .

void makeEmpty(); //empties the linked list

AnyType findID(int ID); // Get the generic type to get the particular id and returns AnyType. Dont remove the object from the list. returns null if the list is empty or ID not found.

boolean insertAtFront(AnyType x); // insert at front of list or return false if that ID already exists

AnyType deleteFromFront(); // delete and return the record at the front of the list or return null if the list is empty

AnyType delete(int ID); // find and delete the record with the given ID or returns null if it isnt found

void printAllRecords(); // print all elements in the order they appear in the linked list. if list is empty print appropriate message.

  1. Write a java class to have the main function, create a linked-list to hold product type objects. It should prompt the user to choice list of the following operations.

  1. Make Empty

/// This Option makes the Linked list empty

  1. Find ID

/// print all details of the product ID, if it is in the list , if not print appropriate message

  1. Insert At Front

/// Get the product magazine details from the user and add it to the front of the list

  1. Delete From Front

///Print the first item on the list and then delete it.

  1. Delete ID

/// Print particular IDed item and then delete it.

  1. Print All Records

// Print all the records in the list

  1. Done

///Quit the program. For every other option after task completion display menu again.

Your program must read from the keyboard and print to the screen.

Sample run

:

Operations on List

  1. Make Empty

  2. Find ID

  3. Insert At Front

  4. Delete From Front

  5. Delete ID

  6. Print All Records

  7. Done

Your choice: 3

Enter Product ID: 1111

Enter Product Name: ABC Book

Enter Supplier Name: Scholastic

Product Added

Operations on List

  1. Make Empty

  2. Find ID

  3. Insert At Front

  4. Delete From Front

  5. Delete ID

  6. Print All Records

  7. Done

Your Choice: 2

ID No: 1111

1111

ABC Book

Scholastic

Operations on List

  1. Make Empty

  2. Find ID

  3. Insert At Front

  4. Delete From Front

  5. Delete ID

  6. Print All Records

  7. Done

Your Choice: 4

1111

ABC Book

Scholastic

First item deleted

Operations on List

  1. Make Empty

  2. Find ID

  3. Insert At Front

  4. Delete From Front

  5. Delete ID

  6. Print All Records

  7. Done

Your Choice: 7

Done.

etc

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

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions

Question

Write short notes on departmentation.

Answered: 1 week ago

Question

What are the factors affecting organisation structure?

Answered: 1 week ago

Question

What are the features of Management?

Answered: 1 week ago

Question

Briefly explain the advantages of 'Management by Objectives'

Answered: 1 week ago

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago