Programming  >  Object-Oriented Programming and Data Structures  >  Arizona State University CSE 205 Expression.java (//Complete Code). (All)

Arizona State University CSE 205 Expression.java (//Complete Code).

Document Content and Description Below

Arizona State University CSE 205 Expression.java /**************************************************************************** // CLASS: Expression.java // // COURSE AND PROJECT INFO // CSE20 ... 5 Object Oriented Programing and Data Structures //**************************************************************************** /** * Represents an infix expression to be evaluated. */ public class Expression { /** * A queue which stores the tokens of the infix expression in the order in * which they were input. */ Queue<Token> mTokenQueue; /** * Expression(String) * * pExprStr is a string representing an infix expression, such as * "(1 + 2) * -3". This ctor uses the Tokenizer class to break the string * into Token objects which are stored in the token queue instance variable. * * PSEUDOCODE: Create a new Queue<Token> object and pass it to setTokenQueue * (this initializes mTokenQueue) Declare and create a Tokenizer object * named tokenizer passing pExprStr to the ctor Declare a Token object named * prevToken initialized to null -- Read the first token Declare a Token * object named token and assign the return value from tokenizer.nextToken() * to it -- Keep reading tokens until tokenizer.nextToken() returns null * While token is not null Do -- Check for and handle the negation operator. * If token instanceof SubOperator Then token = negationCheck(token, pToken) * End if -- Add the token to the queue. Call getTokenQueue().enqueue(token) * prevToken = token -- Read the next token. token = call * tokenizer.nextToken() End While */ public Expression(String pExprStr) { Queue<Token> object = new Queue<Token>(); setTokenQueue(object); Tokenizer tokenizer = new Tokenizer(pExprStr); Token pToken = null; //getTokenQueue(); Token token = tokenizer.nextToken(); while (token != null) { if (token instanceof SubOperator) { token = negationCheck(token, pToken); } getTokenQueue().enqueue(token); pToken = token; token = tokenizer.nextToken(); [Show More]

Last updated: 3 years ago

Preview 1 out of 4 pages

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)
Preview image of Arizona State University CSE 205 Expression.java   (//Complete Code). document

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Reviews( 0 )

$9.00

Buy Now

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Instant download

Can't find what you want? Try our AI powered Search

290
0

Document information


Connected school, study & course


About the document


Uploaded On

Dec 09, 2021

Number of pages

4

Written in

All

Seller


Profile illustration for Kirsch
Kirsch

Member since 6 years

949 Documents Sold

Reviews Received
111
37
8
4
28
Additional information

This document has been written for:

Uploaded

Dec 09, 2021

Downloads

 0

Views

 290

Document Keyword Tags


$9.00
What is Scholarfriends

Scholarfriends.com Online Platform by Browsegrades Inc. 651N South Broad St, Middletown DE. United States.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Scholarfriends · High quality services·