• Post Reply Bookmark Topic Watch Topic
  • New Topic

Instruction Validation  RSS feed

 
Benjamin Milner
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

First of all, hello . Names Ben. Second year Computer Forensics & Security student.

This is a desperation post, I am seriously struggling with my assignment. Normally I am not one to ask for help, I persevere but time is running out .

My course allows me to take in and study all forms of different tech branches, one of them is Software Development. This is not my strongest subject.
I have studied Java for a while but without getting a full grips of the language, programming unfortunatly just will not click for me (as much as I want it to).

My current assignment requries me to develop a graphical drawing tool, one that reads instructions from a text file and analyses the instructions and then presents a graphical drawing to the user.

Now, I have a working GUI, using two panels, one panel with a text form showing the loaded text file with the instructions and a graphical panel. That is requirement 1 (1 out of 4 :/). That is far as I have got without completely tearing my hair out.

The second requirement requires me to make the program examine the instructions within the text file for validity, this includes -- 1. Checking that the instruction itself is known, 2. Checking that the correct number of parameters is provided for that instruction and 3. Checking that the values within the parameteres are on an appropriate type.

instructions such as

MOVE 100 200
LINE 300 200
LINE 300 400
LINE 100 400
LINE 100 200

I am not looking for a straight answer with loads of code. All I would like is for some kind soul to point me the right direction, how to start getting it implamented, an example would be great.
Thank you for everyones time.
Ben

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37462
537
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first thing you'll want to do is loop through each line and spit it up into fields. Luckily String has a split method for that!

1. Checking that the instruction itself is known,

Where is the list of valid instructions stored?

2. Checking that the correct number of parameters is provided for that instruction and

Where is the # parameters per type stored?

3. Checking that the values within the parameteres are on an appropriate type.

What are the valid types? How might you check? For example, if a type is "integer", you check each character is a digit.
 
Benjamin Milner
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:The first thing you'll want to do is loop through each line and spit it up into fields. Luckily String has a split method for that!

1. Checking that the instruction itself is known,

Where is the list of valid instructions stored?

2. Checking that the correct number of parameters is provided for that instruction and

Where is the # parameters per type stored?

3. Checking that the values within the parameteres are on an appropriate type.

What are the valid types? How might you check? For example, if a type is "integer", you check each character is a digit.


Could you show me an example of how this can be done please?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37462
537
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They are questions for you because you know what the valid instructions are. For #1, an example, could be to put them all in a List and use list.contains() to see if you have a match.
 
Campbell Ritchie
Marshal
Posts: 56527
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please search this forum because somebody else has asked a similar question.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!