Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Edit the Dictionary class to include exceptions so that when you run the class DictionaryTest, all tests pass. For example, the method put in the class Dictionary should include the following exception handling:

public void put(String key, Token value) {

if (key == null || value == null) {
throw new NullPointerException("key or value is null");
}

if (count == elems.length) {
increaseCapacity();
}

// Similarly to the array-based implementation
// of a stack, I am adding elements at the end
elems[count] = new Pair(key, value);
count++;
}

LukaSyntaxException

  • Define a new run-time exception named LukaSyntaxException.
  • Make changes to the class Interpreter so that when the following situations are detected, an exception of type LukaSyntaxException is thrown.
    • When an illegal symbol has been found. All illegal symbols are symbols that is nor a reserved keyword (operation), nor an existing association in the dictionary.(Note nor is a Boolean operator that gives the value one if and only if all operands have a value of zero and otherwise has a value of zero.)
    • When undefining a non-existing association.
    • When updating a non-existing association.
  • The class Interpreter will display the appropriate messages, including:
    • The symbol table.
    • Operands stack.
  • Make changes to the class Viewer so that exceptions of type LukaSyntaxException are caught. When catching the exception, the method displays the type of the exception and its message. Finally, the application exits.

For instance, upon executing the following Luka program:

/x 1 def /y 2 def x y /z 3 set

The application would print the following information and exit.

LukaSyntaxException: 
Dictionary: {elems = [{key=y,value=2}, {key=x,value=1}]}
DynamicArrayStack: {3,z,2,1}
ILLEGAL SYMBOL: set
caught LukaSyntaxException

Attachment:- Luka.zip

Java, Programming

  • Category:- Java
  • Reference No.:- M92397774
  • Price:- $15

Priced at Now at $15, Verified Solution

Have any Question?


Related Questions in Java

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As