• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;






 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Now I am super curious what sports would be like if we allowed drugs and tiny ads.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic