Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
duster bask
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is your code with the proper tags. See how much better it looks?

 
duster bask
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for help, Actually I wanted to know my coding is correct or there are some logical errors.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!