Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions Add class named DLNode with a generic type param T Add ivar data of of type T Add ivar prevNode of type DLNode with

Instructions

  • Add class named "DLNode" with a generic type param "T"
  • Add ivar "data" of of type "T"
  • Add ivar "prevNode" of type "DLNode" with sub-type "T"
  • Add ivar "nextNode" of type "DLNode" with sub-type "T"
  • Add a constructor with one parameter that sets the "data" ivar
  • Add a getter for each ivar
  • Add a setter for each ivar
  • Add a method named "hasPrev" with no method params. It should return true if this node has a previous node (is not null)
  • Add a method named "hasNext" similar to "hasPrev" but regarding the next node.

Note Well -- remember to include generic type on DLNode declarations (ivars and other). E.g. declare as "DLNode" and not "DLNode"

Test Code

Write two test code classes.

  • DLSmokeTest
  • DLTest

Each should extend (subclass) the superclass "AbstractTest". They should each test the construction and instance methods on your coded "DLNode" type. They should especially test the methods listed on this page as those are the methods the grader will be using.

Superclass "AbsractTest":

abstract public class AbstractTest { private int testCount; private int failureCount; public AbstractTest() { this.testCount = 0; this.failureCount = 0; } public void assertEquals(Object expected, Object actual) { ++this.testCount; if (!assertEqualsSafely(expected, actual)) { ++this.failureCount; prnf("FAILED (assertEquals) -- actual <%s> vs expected <%s>%n", actual, expected); } } public void assertNotEquals(Object expected, Object actual) { ++this.testCount; if (assertEqualsSafely(expected, actual)) { ++this.failureCount; prnf("FAILED (assertNotEquals) -- actual <%s> vs expected <%s>%n", actual, expected); } } public void assertTrue(boolean condition) { assertEquals(true, condition); } public void fail(String msg) { //Record test as failed prnf("Failed -- " + msg); assertTrue(false); } public static void header(String header) { prn(" Starting test: " + header); } public static void prn(Object o) { System.out.println(o); } public static void prnf(String format, Object... params) { System.out.printf(format, params); } public static void separator() { System.out.println("--------------------------------------------"); } public static void minorSeparator() { System.out.println("-----------"); } public static void cr() { //carriage return new line System.out.println(""); } private boolean assertEqualsSafely(Object a, Object b) { //If only one is nil, then false, use XOR*/ if (a==null ^ b==null) return false; //We now know that if either is null, they both are if (a==null) return true; //Finally a safe equals return a.equals(b); } public void printSummary() { cr(); prnf("Test Results for test -- %s%n", this.getClass().getSimpleName()); int n, f, p; n = this.testCount; f = this.failureCount; p = n - f; if (n == 0) return; double percent = 100.0 * p / n; prnf("Test Count: %d%n", n); prnf("Failure Count: %d%n", f); prnf("Passing Percent: %.1f%%%n", percent); separator(); } } 

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_2

Step: 3

blur-text-image_3

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 And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions

Question

5. How do instructional objectives help learning to occur?

Answered: 1 week ago

Question

4. Help trainees set challenging mastery or learning goals.

Answered: 1 week ago