Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

from java algorithms classes. 4.29 - Modify the MemoryCell to implement Comparable Because the MemoryCell class uses objects as instance variables we can't figure out

from java algorithms classes.

4.29 - Modify the MemoryCell to implement Comparable

Because the MemoryCell class uses objects as instance variables we can't figure out a sorted order. So we will use the GenericMemoryCell class from above as it already has a more general AnyType in it.

The first step is to get those instance variables to not be AnyType, but to be AnyType that extends comparable

You can then finish the compareTo method so that it properly implements Comparable as asked.

the code below.

public class GenericMemoryCell implements Comparable> {

private AnyType storedValue;

public AnyType read( ) { return storedValue; } public void write( AnyType x ) { storedValue = x; }

@Override public int compareTo(GenericMemoryCell o) { // TODO Finish this method return (int)(Math.random()*10-5); }

}

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

DB2 9 For Linux UNIX And Windows Advanced Database Administration Certification Certification Study Guide

Authors: Roger E. Sanders, Dwaine R Snow

1st Edition

1583470808, 978-1583470800

More Books

Students also viewed these Databases questions

Question

1-2 Explain the different variables of the marketing ri,ix.

Answered: 1 week ago

Question

find all matrices A (a) A = 13 (b) A + A = 213

Answered: 1 week ago