Write a class array that encapsulates an array

Assignment Help JAVA Programming
Reference no: EM1317340

2. Before we developed a StringLog ADT. It represents a "log" that holds objects of class String. Suppose that instead of restricting ourselves to strings, we decided to create a  "log" that holds objects of type Object. Describe the changes you would have to make to each of the following classes to implement such a change.

a. Change StringLogInterface to ObjectLogInterface

b. Change ArrayStringLog to ArrayObjectLog

c. Change ITDArrayStringLog to ITDArrayObjectLog

d. Change LLStringNode to LLObjectNode

e. Change LinkedStringLog to LinkedObjectLog

2. Write a class Array that encapsulates an array and provides bounds-checked access. The private instance variables should be int index and inarray[10]. The public members should be a default constructor and methods (signatures shown below) to provide read and write access to the array.

void insert(int location, int value);

void retrieve(int location);

If the location is within the correct range for the array, the insert method should set that location of the array to the value. Likewise, if the location is within the correct range for the array, the retrieve method should return the value at that location--the approach taken by the library before Java 5.0. In either case, if location is not within the correct range, the method should throw an exception of class ArrayOutOfBoundsException. Write an application that helps you test your implementation. Your application should assign values to the array by using the insert method, then use the retrieve method to read these values back from the array. It should also try calling both methods with illegal location values. Catch any exceptions thrown by placing the "illegal" calls in a try block with an appropriate catch. Share your code with classmates and compare and discuss the various implementations.

Reference no: EM1317340

Questions Cloud

Research and writing : Research and Writing: Brief Assignment,  Review the fact pattern provided below. At this time, Mr. Kant stands convicted of either petit larceny or shoplifting, as dictated by your state statutes,
Measure the distance pa, pb, pc : Measure the distance PA, PB, PC etc. from p to various point with chain or tape and plot them to scale along the co responding rays. Join the points a, b, c, etc. to give outline of survey.
Insert uml design diagrams, use case, classes : Insert UML design diagrams here (use case, class, and sequence diagram).
Create your own date class : You are to write a program that determines the day of the week for New Year's Day in the year 3000. To do this, you must create your own date class (MyDate) and use the following interface and main program:
Write a class array that encapsulates an array : Write a class Array that encapsulates an array and provides bounds-checked access. The private instance variables should be int index and inarray[10]. The public members should be a default constructor and methods (signatures shown below) to provide ..
Uml exercise : UML Exercise: Automated Teller Machine (ATM),   1. To allow authorized card holders to make transactions,   Brief Summary of Requirements:
What is economics system : What is economics system? What are the types of economics system? Briefly explain each type of economics system by giving examples of nations that are close to each type
A sewage treatment works stw : A sewage treatment works (STW) with 4 single-stage trickling filters has become organically overloaded due to the discharge of a biodegradable industrial effluent to the STW. This is causing effluent to pond on the surface of the filters.
Use an article that simply explains : use an article that simply  explains or describes  something (8 Steps to...; How to...; etc.). Find an article on this in a professional journal in your field and be sure that the author is making a case for something. Then:

Reviews

Write a Review

JAVA Programming Questions & Answers

  Java program simulate a network

Java program simulate a network

  Represent one book in java

Represent one book in java

  Web engineering principles

web application development, Web Engineering methodology, UML-based Web Engineering (UWE), models to the expansion of web applications, Object Oriented Web Solutions (OOWS),Web Modeling Language (WebML) methodology, Object-Oriented Hypermedia Design..

  Write a recursive program

Write a recursive program to compute the number of ways in which an integer k can be written as sum

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  The frantic pipe layer game

Design the Frantic Pipe Layer game

  Data structures and algorithms

Code analysis and programming.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Technical community blog

Write a blog article for a coding/technical community blog

  Solving programming problems

Write a computer program that will figure out the total of an order when given the amount of the order ($1000) and a sales tax rate of eight percent.

  Methods

Assignment describe the basic working of methods. How to write a method in java and how to call a method.

  Print the contents of the array

Prepare a second loop that prints the contents of the array

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd