Implement linked based list and ADTs in Java, fullfilling all conditions listed below Remember to use the code images below for data attributes: A LinkNode structure or class which will have two attributes - a data attribute and a pointer attribute to the next node.  The data attribute of the LinkNode should be the Money class of Lab 1. A Singly Linked List class which will be composed of three attributes - a count attribute, a LinkedNode pointer/reference attribute pointing to the start of the list and a LinkedNode pointer/reference attribute pointing to the end of the list. Since this is a class, make sure all these attributes are private. The attribute names for the Node and Linked List are the words in bold in #1 and #2.  For the Linked List, implement the most common linked-list behaviors as explained in class - getters/setters/constructors/destructors for the attributes of the class, (a) create new list, (b) add data, (c) delete data, (d) find data, (e) count of data items in the list, (f) is list empty, (g) empty/destroy the list and (h) print all data items in a list. Note: create new list can be the constructor and destroy list can be the destructor or garbage collector. Note 2: It will be helpful if you define specific add/delete/find methods for the first and last position of the list. Any other methods you think would be useful in your program. A Stack class derived from the Linked List but with no additional attributes and the usual stack methods - (a) create stack, (b) push, (c) pop, (d) peek, and (e) destroy/empty the stack. Similar to above, create can be the constructor etc. A Queue class derived from the Linked List but with no additional attributes and the usual queue methods - (a) create queue, (b) enqueue, (c) dequeue, (d) peekFront, (e) peekRear, and (f) destroy/empty the queue. Similar to above, create can be the constructor etc. Ensure that all your classes are mimimal and cohesive with adequate walls around them. Try to reuse and not duplicate any code. You are allowed to define interfaces as needed, so you can reuse them in your project. Then write a main driver program that will demonstrate all the capabilities of your ADTs as follows - Create seven (7) Node objects of Money class to be used in the program. Demonstrate the use of your LinkedList with the seven USD Node objects inserted/deleted/searched in a random order.  Remember, you will need to print the contents of the List several times to demonstrate the functionality. Demonstrate the use of your Stack with the same seven USD Node objects pushed/popped/peeked in a random order different from the one in LinkedList. Demonstrate the use of your Queue with the same seven USD Node objects enqueued/dequeued/peeked in a random order different from both the LinkedList and Stack. Demonstrate use of all the methods above by providing sufficient information to screen for actions being taken. Restrict all your input / output to the main driver program only. For submission, code your LinkNode and LinkedList in one file and Stack and Queue in a separate file. Remember to include the code file(s) for your Currency and Money classes. Also, your 'main' which is the driver program should be in a separate file of its own. Additionally, you will include your output text file as well as screenshots of the console run. Remember to include pre/post documentation and comment blocks as necessary in your code files.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Implement linked based list and ADTs in Java, fullfilling all conditions listed below Remember to use the code images below for data attributes:

  1. A LinkNode structure or class which will have two attributes - a data attribute and a pointer attribute to the next node.  The data attribute of the LinkNode should be the Money class of Lab 1.
  2. A Singly Linked List class which will be composed of three attributes - a count attribute, a LinkedNode pointer/reference attribute pointing to the start of the list and a LinkedNode pointer/reference attribute pointing to the end of the list. Since this is a class, make sure all these attributes are private.
  3. The attribute names for the Node and Linked List are the words in bold in #1 and #2. 
  4. For the Linked List, implement the most common linked-list behaviors as explained in class -
    1. getters/setters/constructors/destructors for the attributes of the class,
    2. (a) create new list, (b) add data, (c) delete data, (d) find data, (e) count of data items in the list, (f) is list empty, (g) empty/destroy the list and (h) print all data items in a list. Note: create new list can be the constructor and destroy list can be the destructor or garbage collector. Note 2: It will be helpful if you define specific add/delete/find methods for the first and last position of the list.
    3. Any other methods you think would be useful in your program.
  5. A Stack class derived from the Linked List but with no additional attributes and the usual stack methods - (a) create stack, (b) push, (c) pop, (d) peek, and (e) destroy/empty the stack. Similar to above, create can be the constructor etc.
  6. A Queue class derived from the Linked List but with no additional attributes and the usual queue methods - (a) create queue, (b) enqueue, (c) dequeue, (d) peekFront, (e) peekRear, and (f) destroy/empty the queue. Similar to above, create can be the constructor etc.
  7. Ensure that all your classes are mimimal and cohesive with adequate walls around them. Try to reuse and not duplicate any code. You are allowed to define interfaces as needed, so you can reuse them in your project.
  8. Then write a main driver program that will demonstrate all the capabilities of your ADTs as follows -
    1. Create seven (7) Node objects of Money class to be used in the program.
    2. Demonstrate the use of your LinkedList with the seven USD Node objects inserted/deleted/searched in a random order.  Remember, you will need to print the contents of the List several times to demonstrate the functionality.
    3. Demonstrate the use of your Stack with the same seven USD Node objects pushed/popped/peeked in a random order different from the one in LinkedList.
    4. Demonstrate the use of your Queue with the same seven USD Node objects enqueued/dequeued/peeked in a random order different from both the LinkedList and Stack.
    5. Demonstrate use of all the methods above by providing sufficient information to screen for actions being taken.
    6. Restrict all your input / output to the main driver program only.
  9. For submission, code your LinkNode and LinkedList in one file and Stack and Queue in a separate file. Remember to include the code file(s) for your Currency and Money classes. Also, your 'main' which is the driver program should be in a separate file of its own. Additionally, you will include your output text file as well as screenshots of the console run.
  10. Remember to include pre/post documentation and comment blocks as necessary in your code files.
// abstract base class called Currency with two integers attributes
public abstract class Currency {
1
35 }
public class Money extends Currency{
//coin value is greater than 10 cents
if(super.getCoinValue() > 10){
return(super.getNoteValue() +
} else{
return(super.getNoteValue() + ".0" + currencyName + " " + super.getCoinValue() + " " + coinName);
}
35
int coins = super.getCoinValue() - other.getCoinValue();
67
36
private String currencyName;
36
//if no coins
68
3
protected int noteValue;
3
private String coinName;
+ currencyName +
37
if(coins < 0){
69
+ super.getCoinValue() + " " + coinName );
II I|
protected int coinValue;
4.
38
//increment the ntoes count
70
public Money(O{
super();
this.currencyName
II II
39
notes --;
71
public Currency(){
40
//decrement 100 from coins
72
7
this.noteValue
0;
7
"Dollar";
41
coins += 100;
73
}
this.coinValue
0;
8.
this.coinName
"Cent";
42
}
74
}
%3|
9.
}
9.
}
43
return new Money (notes,coins);
75
public Currency(int noteValue, int coinValue){
public Money(int noteValue, int coinValue){
super(noteValue, coinValue);
this.currencyName
10
10
44
}
76
11
this.noteValue
noteValue;
11
public int compareCurrency(Currency currency){
(Money) currency;
45
77
12
this.coinValue
coinValue;
12
"Dollar";
Money other
if(this.getNoteValue() > other.getNoteValue())
46
13
}
13
this.coinName
"Cent";
47
14
public Currency(Currency currency){
14
}
48
return 1;
15
this.noteValue
currency.noteValue;
public Currency addCurrency(Currency currency){
else if(this.getNoteValue() < other.getNoteValue())
15
49
16
this.coinValue = currency.coinValue;
//Cast the currency to be Money
Money other = (Money) currency;
16
50
return -1;
17
}
17
51
else if(this.getCoinValue() > other.getCoinValue())
18
18
//get notes and coins value
52
return 1;
super.getNoteValue() + other.getNoteValue();
super.getCoinValue() + other.getCoinValue();
19
public int getNoteValue(){
19
int notes
else if(this. getCoinValue() < other.getCoinValue())
53
20
return noteValue;
20
int coins
54
return -1;
21
}
//if coins is greater than 100
if(coins >= 100){
21
55
else return 0;
22
public void setNoteValue(int noteValue){
22
56
}
23
this.noteValue
noteValue;
23
//increment the notes count
public void printCurrency(){
//coin value is greater than 10 cents
if(super.getCoinValue() > 10){
System.out.println(super.getNoteValue() + " " + currencyName + " " + super.getCoinValue() + " "+ coinName);
} else{
System.out.print(super.getNoteValue() + ".0" + currencyName +
57
24
}
24
notes++;
58
25
public int getCoinValue(){
25
//decrement 100 from coins
59
26
return coinValue;
26
coins
-= 100;
60
II II
27
}
27
}
61
28
public void ssetCoinValue(int coinValue){
28
return new Money(notes,coins);
+ super.getCoinValue()+
+ coinName);
62
29
this.coinValue
coinValue;
29
}
63
}
30
}
30
public Currency subtractCurrency(Currency currency){
64
}
public abstract Currency addCurrency(Currency c);
public abstract Currency subtractCurrency(Currency c);
public abstract int compareCurrency(Currency c);
public abstract void printCurrency();
31
//Cast the currency to be Money
(Money) currency;
31
65
@Override
32
32
Money other
66
public String toString(){
33
33
// get ntoes and coins value
34
34
int notes =
super.getNoteValue() - other.getNoteValue();
4 5
6
8
Transcribed Image Text:// abstract base class called Currency with two integers attributes public abstract class Currency { 1 35 } public class Money extends Currency{ //coin value is greater than 10 cents if(super.getCoinValue() > 10){ return(super.getNoteValue() + } else{ return(super.getNoteValue() + ".0" + currencyName + " " + super.getCoinValue() + " " + coinName); } 35 int coins = super.getCoinValue() - other.getCoinValue(); 67 36 private String currencyName; 36 //if no coins 68 3 protected int noteValue; 3 private String coinName; + currencyName + 37 if(coins < 0){ 69 + super.getCoinValue() + " " + coinName ); II I| protected int coinValue; 4. 38 //increment the ntoes count 70 public Money(O{ super(); this.currencyName II II 39 notes --; 71 public Currency(){ 40 //decrement 100 from coins 72 7 this.noteValue 0; 7 "Dollar"; 41 coins += 100; 73 } this.coinValue 0; 8. this.coinName "Cent"; 42 } 74 } %3| 9. } 9. } 43 return new Money (notes,coins); 75 public Currency(int noteValue, int coinValue){ public Money(int noteValue, int coinValue){ super(noteValue, coinValue); this.currencyName 10 10 44 } 76 11 this.noteValue noteValue; 11 public int compareCurrency(Currency currency){ (Money) currency; 45 77 12 this.coinValue coinValue; 12 "Dollar"; Money other if(this.getNoteValue() > other.getNoteValue()) 46 13 } 13 this.coinName "Cent"; 47 14 public Currency(Currency currency){ 14 } 48 return 1; 15 this.noteValue currency.noteValue; public Currency addCurrency(Currency currency){ else if(this.getNoteValue() < other.getNoteValue()) 15 49 16 this.coinValue = currency.coinValue; //Cast the currency to be Money Money other = (Money) currency; 16 50 return -1; 17 } 17 51 else if(this.getCoinValue() > other.getCoinValue()) 18 18 //get notes and coins value 52 return 1; super.getNoteValue() + other.getNoteValue(); super.getCoinValue() + other.getCoinValue(); 19 public int getNoteValue(){ 19 int notes else if(this. getCoinValue() < other.getCoinValue()) 53 20 return noteValue; 20 int coins 54 return -1; 21 } //if coins is greater than 100 if(coins >= 100){ 21 55 else return 0; 22 public void setNoteValue(int noteValue){ 22 56 } 23 this.noteValue noteValue; 23 //increment the notes count public void printCurrency(){ //coin value is greater than 10 cents if(super.getCoinValue() > 10){ System.out.println(super.getNoteValue() + " " + currencyName + " " + super.getCoinValue() + " "+ coinName); } else{ System.out.print(super.getNoteValue() + ".0" + currencyName + 57 24 } 24 notes++; 58 25 public int getCoinValue(){ 25 //decrement 100 from coins 59 26 return coinValue; 26 coins -= 100; 60 II II 27 } 27 } 61 28 public void ssetCoinValue(int coinValue){ 28 return new Money(notes,coins); + super.getCoinValue()+ + coinName); 62 29 this.coinValue coinValue; 29 } 63 } 30 } 30 public Currency subtractCurrency(Currency currency){ 64 } public abstract Currency addCurrency(Currency c); public abstract Currency subtractCurrency(Currency c); public abstract int compareCurrency(Currency c); public abstract void printCurrency(); 31 //Cast the currency to be Money (Money) currency; 31 65 @Override 32 32 Money other 66 public String toString(){ 33 33 // get ntoes and coins value 34 34 int notes = super.getNoteValue() - other.getNoteValue(); 4 5 6 8
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY