Computer Science Canada Phonetic Alphabet |
Author: | SkaarjSlayer [ Thu Sep 25, 2008 4:27 pm ] |
Post subject: | Phonetic Alphabet |
Here is a better and slightly more complicated program that took me 2 hours to create. I normally would have posted the code but it's 5917 lines of code so I won't spam it on here. In the .zip is included the .exe file as well as the original .t file so don't worry, you can still view the code before running the program. For those who don't know what the phonetic alphabet is, it's more commonly used over radio especially with the military. Each letter of the alphabet has a corresponding word for it. For example: A = Alpha B = Bravo C = Charlie D = Delta E = Echo F = Foxtrot and so on. Now, this program will let you input any word with a maximum of up to 10-letter words and translate it into the phonetic alphabet (any words over 10 letters will not work) The 2 annoying things about this program is that A) you'll have to FIRST input how many letters are in the word and THEN input the actual word and B) the first letter must be capitalized. To give an example of how the program will work, say you wanted to translate the word CAKE. Well, CAKE is 4 letters so you tell the program it has 4 letters and then you input "Cake". The program will then translate it as: Charlie Alpha Kilo Echo Simple, no? Now, this program is overly long and complicated and I know there's simpler code to make this program work, but this is how it is written so try to enjoy and tell me what you think. (Warning: Almost no indentation and extremely little internal documentation.) |
Author: | gitoxa [ Thu Sep 25, 2008 4:34 pm ] | ||
Post subject: | RE:Phonetic Alphabet | ||
Turing has a length function that you can use to get the length of the word
And you should be able to use string manipulation to change any letters to upper/lower case, or not accept them if they're not right (input error checking) |
Author: | Insectoid [ Thu Sep 25, 2008 4:35 pm ] |
Post subject: | RE:Phonetic Alphabet |
to get around entering the number of characters, use the length () command. It returns the amount of characters in the string. Why did this take over 5000 lines? It fairly simple, using a for loop and some big if statements. EDIT: darn you Gitoxa, you beat me by 1 minute! |
Author: | gitoxa [ Thu Sep 25, 2008 4:36 pm ] |
Post subject: | RE:Phonetic Alphabet |
Yea, a for loop would have probably benefited you big time... wow. @insectoid: You're too slow |
Author: | Insectoid [ Thu Sep 25, 2008 4:38 pm ] |
Post subject: | RE:Phonetic Alphabet |
With a for loop, you could also translate any size of word, instead of having a 10 word limit |
Author: | SkaarjSlayer [ Thu Sep 25, 2008 4:38 pm ] |
Post subject: | Re: Phonetic Alphabet |
well I did gitoxa's original suggestion but it had a logic error and didn't do what I wanted it to so the program ended up taking over 5000 lines. IMO: As long as it works |
Author: | Insectoid [ Thu Sep 25, 2008 4:40 pm ] |
Post subject: | RE:Phonetic Alphabet |
IMO: As long as it works AND doesn't fill my hard drive with unnecessary inefficient code. |
Author: | gitoxa [ Thu Sep 25, 2008 4:41 pm ] |
Post subject: | RE:Phonetic Alphabet |
That's a bad opinion to have, to be honest. It took you over two hours to write a program that really should have taken maybe 10-15 mins. The hardest part is getting all the codewords setup into one if/case structure. What was this 'logic error' ? |
Author: | Insectoid [ Thu Sep 25, 2008 4:43 pm ] |
Post subject: | RE:Phonetic Alphabet |
who's opinion? Mine or his? |
Author: | SkaarjSlayer [ Thu Sep 25, 2008 4:44 pm ] |
Post subject: | Re: Phonetic Alphabet |
Not quite bad, if it were a program that took much more than 1 MB then there'd be cause for concern.. or if you have a very crappy computer. To be honest, I don't quite remember, it just wouldn't work with every letter in the code for some reason and the only way I found it to work was the way I did it. I'd like to point out that I'm not the greatest coder and so what might've taken *you* 10-15 minutes, well, not everyone is the same. |
Author: | Insectoid [ Thu Sep 25, 2008 4:47 pm ] |
Post subject: | RE:Phonetic Alphabet |
Meh, you'll get faster. By the end of the semester you'll be typing out multiple-hundred-line programs where no line is unnecessary in a mere hour. |
Author: | gitoxa [ Thu Sep 25, 2008 4:47 pm ] |
Post subject: | RE:Phonetic Alphabet |
insectoid, his. And it took me 2 minutes, so I think 10-15 is a good estimation. |
Author: | The_Bean [ Thu Sep 25, 2008 4:47 pm ] |
Post subject: | Re: Phonetic Alphabet |
An easy way to do it would be to set up the codewords in an array then call them out corresponding to the ascii value of the that letter. and why are you importing the entire GUI class when you only use it for GUI.SetBackgroundColour (black) |
Author: | SkaarjSlayer [ Thu Sep 25, 2008 4:52 pm ] |
Post subject: | Re: Phonetic Alphabet |
I first started using Turing since about February of this year. I'm sure you'll say "I learned it in 'this' much time" and "It's not that hard." but IMO that's pretty ignorant. There's lots of stuff I absolutely do not know about Turing and I'm learning as I go. I can accept criticism but don't assume I know everything you people know. |
Author: | gitoxa [ Thu Sep 25, 2008 4:55 pm ] |
Post subject: | RE:Phonetic Alphabet |
I'm not assuming you should know everything, but when a simple program is taking 5000+ lines to make, you should be thinking to yourself "is this right?" |
Author: | Insectoid [ Thu Sep 25, 2008 4:57 pm ] |
Post subject: | RE:Phonetic Alphabet |
We aren't assuming you know these things. We are helping you, and if we tell you to use something you don't know of, or use a word you haven't learned, feel free to ask about it, and we'll explain in greater detail |
Author: | SkaarjSlayer [ Thu Sep 25, 2008 4:58 pm ] |
Post subject: | Re: Phonetic Alphabet |
No, I didn't think it was right, but I thought I'd like to share. I put this up to get tips and I'll accept suggestions to make it more efficient and better but I don't like hearing "Well *I* can do it in 2 minutes, why can't you do it in 15?" |
Author: | The_Bean [ Thu Sep 25, 2008 4:59 pm ] | ||
Post subject: | Re: Phonetic Alphabet | ||
|
Author: | Insectoid [ Thu Sep 25, 2008 4:59 pm ] |
Post subject: | RE:Phonetic Alphabet |
It's a programmer thing. |
Author: | SkaarjSlayer [ Thu Sep 25, 2008 5:01 pm ] |
Post subject: | Re: Phonetic Alphabet |
Alright. And thanks Bean, but I have to admit that's beyond my knowledge of Turing |
Author: | gitoxa [ Thu Sep 25, 2008 5:03 pm ] |
Post subject: | Re: Phonetic Alphabet |
SkaarjSlayer @ Thu Sep 25, 2008 4:58 pm wrote: No, I didn't think it was right, but I thought I'd like to share. I put this up to get tips and I'll accept suggestions to make it more efficient and better but I don't like hearing "Well *I* can do it in 2 minutes, why can't you do it in 15?"
That isn't at all what I said, you're trying to make me out as a larger a**hole than I am. I simply said it hsould not have taken you 2 hours, because a large portion of this time was spent copying + pasting a new if structure, and adding more to the end of it. If you hadn't been so defensive, you probably would have understood that. |
Author: | SkaarjSlayer [ Thu Sep 25, 2008 5:05 pm ] |
Post subject: | Re: Phonetic Alphabet |
I know what my program does and I know it can be done way more efficiently, as I was just shown. I apologize for jumping on you like that, I'm just normally used to people saying "I can do it better." |
Author: | Insectoid [ Thu Sep 25, 2008 5:08 pm ] |
Post subject: | RE:Phonetic Alphabet |
I think this topic has strayed far enough from it's original course. If it doesn't turn back, it may be locked (how I wish I had mod powers..) |
Author: | [Gandalf] [ Thu Sep 25, 2008 5:58 pm ] |
Post subject: | RE:Phonetic Alphabet |
Deal. SkaarjSlayer, you'd definitely save a lot of time and become more knowledgeable, maybe even wiser if you learn loops and other nifty things like functions. Take a look at the Turing Walkthrough in the tutorials forum. |