Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes In your lab05, replace instructor’s Tokenizer class and MyStackQueue package with your own. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "In your lab05, replace instructor’s Tokenizer class and MyStackQueue package with your own. " Watch "In your lab05, replace instructor’s Tokenizer class and MyStackQueue package with your own. " New topic
Author

In your lab05, replace instructor’s Tokenizer class and MyStackQueue package with your own.

duster bask
Greenhorn

Joined: Oct 09, 2012
Posts: 2
Objective:

The objective of this lab is to get you some experience in processing strings character by
character and in implementing stacks and queues in a class package.

The programming assignment:
In your lab05, replace instructor’s Tokenizer class and MyStackQueue package with your own.

Requirements:
1. You must use an array to implement your queue.
2. You must use a linked list to implement your stack.
3. You must use the following frame work to implement your tokenizer.
class Tokenizer {
private char [] Buf;
private int cur;
Tokenizer(String infixExpression) {
Buf = infixExpression.toCharArray();
cur = 0;
}
Token nextToken() {
1. Skip blanks.

2. if (cur>=Buf.length) return null;

3. If the next character is a digit, keep reading until a non-digit is read.

Convert the string of digits into an integer.
String Digits = new String(Buf, start, len);
int num = Integer.valueOf(Digits).intValue();
Create and return an operand.
4. Otherwise, use the next character to create and return an operator.
}
}


I have developed these classes is it correct?


package StackAndQueue;






Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 5893
    
    6

Hi, and welcome to the Ranch!

Before we get started, there are a few things you should know.

First, you need to TellTheDetails(←click). We can't help you if you're not clear and specific about what problem you're having. As for your question, "Is it correct?" only your instructor can answer that for sure, because only he knows what he's looking for. You can and should run your code with some test data to see if it does what the assignment says it should. If it does, there's a good chance it's correct, or at least mostly so. If not, then you still have work to do.

Additionally, when posting code, please UseCodeTags(←click) so that it will be readable. You can edit your original post and add them.

Thanks, and good luck!
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9955
    
    6

Here is your code with the proper tags. See how much better it looks?


Never ascribe to malice that which can be adequately explained by stupidity.
duster bask
Greenhorn

Joined: Oct 09, 2012
Posts: 2
Thank you very much for help, Actually I wanted to know my coding is correct or there are some logical errors.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 5893
    
    6

duster bask wrote:Thank you very much for help, Actually I wanted to know my coding is correct or there are some logical errors.


As I said in my first reply: As for your question, "Is it correct?" only your instructor can answer that for sure, because only he knows what he's looking for. You can and should run your code with some test data to see if it does what the assignment says it should. If it does, there's a good chance it's correct, or at least mostly so. If not, then you still have work to do.

So, test it.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: In your lab05, replace instructor’s Tokenizer class and MyStackQueue package with your own.
 
Similar Threads
final and protected method at the same time
need a postfix for calculation
java.lang.NullPointerException at runtime
Queue Algorithm Doubt
Convert Queue Dequeue to Link list format