Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How does the show() method in the derived class overwrite the show() method of the base class? Because the current in current.show() is a node
- How does the show() method in the derived class overwrite the show() method of the base class? Because the current in current.show() is a node and not a FloatNode.
/Class Node class Node // data private Node next; constructor public Node () next null; I console display public void show() System.out.print("(generic node) "); /I insert after public void insertAfter (Node newNode) if (newNodenull) return; newNode.next next; next newNode /Iremove after public Node removeAfterO Node tempnext if (temp-null) next temp.next; return temp; // returning the next member public Node getNext() return next; class FloatNode extends Node // additional data for subclass private double data; Iconstructor public FloatNode (double x) super; II constructor call to base class datax; // overriding show() public void show( NumberFormat tidy = NumberFormat.getinstance(Locale.US); tidy.setMaximumFractionDigits (4); System.out.print("[" + tidy.format(data) "); // assessor and mutator public double getData) return data public boolean setData(double usrData) // if there were a viable limitation we would test and return fa datausrData; return true; //Class List class List // pointer to first node in stack private Node head, current; /Iconstructor public List) // an empty list will have one "header" node at the front headnew Node ); current null ; protected void insertAfterHead (Node newNode) head.insertAfter (newNode); protected Node removeAfterHead() return head. removeAfter); /I console display public void showList) System.out.print1n( .. \ Here's the List for (current= head; (current= current . getNext()) n" !=null; ) current.show); System.out.print(" "); System.out.println "nn That's all! protected Node getCurrent() return current; protected void resetCurrent() currenthead; protected Node iterate() if (current-null) current-current.getNext); return current; import java.util.*; import java.text.*; public class Foothill public static void main (String[] args) FloatNode fp; List myList new List(); int k; // build a data-less list by inserting 10 nodes at front for (k = 0; k
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started