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

  Develop a gui based java program

Designing and developing a College Registration program

  Java project

Prompt the user for an int between lower and upper boundary.

  Implementation the two classes

Program Specifications: In the new implementation, the two classes, Student and Grades, are defined with the following operations/methods.

  Communication with an smtp server

Develop a graphical user interface based java program that can communicate with a real SMTP email server for sending emails

  Write a recursive program

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

  Socket programming in java: tcp

In this project we will develop a Web server in two steps. In the end, you will have built a multi-threaded Web server that is capable of processing multiple simultaneous service requests in parallel.

  Design a single class that expresses the commonality

Design a single class that expresses the commonality of these concepts.

  Implementation activities of software development

Analysis, design, and implementation activities of software development

  User session mgr - socket and thread programs

User Session Mgr - Socket and Thread Programs

  Implement a class quiz

Implement a class Quiz that implements the Measurable interface.

  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.

  Cascading style sheet to a website

Compare and contrast the process of adding JavaScript and a Cascading Style Sheet to a Website. Determine if they can be used simultaneously in a page.

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