The Artima Developer Community
Sponsored Link

Legacy Design Forum
Designing with Interfaces



This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


sample code

Posted by phil healy on November 20, 2000 at 2:14 PM

would u have any code for the following 4 questions

Problem 6.1 Write code for an array-implementation of the well-known stack operations push(e), pop(), and isEmpty(), such that they would support Objects rather than simply ints as given in lectures.

Problem 6.2 Write an ADT function in Java that takes an array (possibly containing multiple occurances of particular elements) and returns an array with all duplicates of elements removed. When comparing array elements use the boolean equals(Object e) method that many ADTs in Java support. So, where one might have used (list[1]==list[2]) when comparing int array elements, one will use (list[1].equals(list[2])) when comparing Object array elements. This is to avoid comparing references (or addresses in memory) of objects when we mean to compare the value of objects.

Problem 6.3 Write a class in Java that specifies an ADT to store an array of Objects. Besides constructors, it should have a toString() method and a removeDuplicates() method. Also write a tester program.

Problem 6.4 Write a class in Java that specifies an ADT to store an array of Lab06C objects. Besides constructors, it should have a totalSiblings() method and a toString() method. The totalSiblings() method should return the total sum of the siblings of each person in the array. Also write a tester program.

if u can could u please reply very soon


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us