Author Topic: My first programming exercise for college  (Read 14644 times)

0 Members and 1 Guest are viewing this topic.

uncoolperson

  • Guest
Re: My first programming exercise for college
« Reply #30 on: January 19, 2011, 09:16:42 PM »
I got a fun one coming up... just gotta wait for it to be assigned (the for me to do it), and I'll post it here as a challenge.

(involves recursion!!!)

I ain't doin' ya homewerk buddy

that's why I was going to wait until I was done.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: My first programming exercise for college
« Reply #31 on: January 19, 2011, 09:20:47 PM »
:-P  :-P
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

uncoolperson

  • Guest
Re: My first programming exercise for college
« Reply #32 on: January 19, 2011, 09:24:01 PM »
just trust me dude... it'll be a lot more entertaining then hello world in a couple of languages

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: My first programming exercise for college
« Reply #33 on: January 19, 2011, 11:35:10 PM »
just trust me dude... it'll be a lot more entertaining then hello world in a couple of languages

Hey now ... I was at least a bit creative and used Klingon (I hope the instructor has a sense of humor)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Jeff H

  • Needs a day job
  • Posts: 6144
Re: My first programming exercise for college
« Reply #34 on: January 19, 2011, 11:44:37 PM »
just trust me dude... it'll be a lot more entertaining then hello world in a couple of languages

Hey now ... I was at least a bit creative and used Klingon (I hope the instructor has a sense of humor)

I was going to post that probably some nerd wrote a computer language in klingon, but decided to google it and was right.

Quote
Klingon computer programming language
Var'aq is a programming language for those that speak Klingon. Here's "Hello world" in var'aq:

~ nuqneH { ~ 'u' ~ nuqneH disp disp } name
nuqneH

Roughly translated, it means "What do you want, universe?"

http://kottke.org/03/01/klingon-computer-programming-language

http://www.trektoday.com/news/070800_05.shtml



uncoolperson

  • Guest
Re: My first programming exercise for college
« Reply #36 on: January 20, 2011, 12:05:15 AM »
just trust me dude... it'll be a lot more entertaining then hello world in a couple of languages

Hey now ... I was at least a bit creative and used Klingon (I hope the instructor has a sense of humor)

I don't care that no one ever see's it, inserting fun is well... just fun.

Code: [Select]
FUNCTION Tales_From_The_Cryption_Keeper
Code: [Select]
Put("Sorry Jack Ryan, you don't have high enough clearance for that");

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: My first programming exercise for college
« Reply #37 on: January 20, 2011, 12:39:40 AM »
just trust me dude... it'll be a lot more entertaining then hello world in a couple of languages

Hey now ... I was at least a bit creative and used Klingon (I hope the instructor has a sense of humor)

I was going to post that probably some nerd wrote a computer language in klingon, but decided to google it and was right.

Quote
Klingon computer programming language
Var'aq is a programming language for those that speak Klingon. Here's "Hello world" in var'aq:

~ nuqneH { ~ 'u' ~ nuqneH disp disp } name
nuqneH

Roughly translated, it means "What do you want, universe?"

http://kottke.org/03/01/klingon-computer-programming-language

http://www.trektoday.com/news/070800_05.shtml



Well, your source is close ... the actual text would be
Quote
nuqneH qo'

nuqneH: what do you want? Greetings (excl.)

qo':  world, realm (n)


But then I also took the liberty of changing the other text on the form as well ... for example, instead of "Exit" I put

Quote
Qaw' ngoqDe'

Qaw': destroy (v)

ngoqDe': code - encoded message (n)


So, basically telling the user to "destroy encoded message"
It isn't exactly 100%, but any person capable of understanding Klingon would understand the phrase.

Another little thing I added was to change the window title to the language of choice. The instructor said to put our name in the title along with the Hello World phrase. In English it would be "Hello World - By Keith™" but in Klingon it is as so:

Quote
nuqneH qo' - ghajwI' Keith™

nuqneH: what do you want? Greetings (excl.)

qo': world, realm (n)

ghajwI':  one/thing which is/does/   have, possess (v)  


Roughly translated to: Hello World - Owner Keith™

It was quite fun ;-) I think maybe I'll do more Klingon stuff in the future ... as long as this doesn't backfire on me ;-)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

uncoolperson

  • Guest
Re: My first programming exercise for college
« Reply #38 on: February 08, 2011, 07:36:20 PM »
just trust me dude... it'll be a lot more entertaining then hello world in a couple of languages


just turned in my recursive soduko solver...

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: My first programming exercise for college
« Reply #39 on: February 09, 2011, 12:13:38 AM »
So, my instructor gave me 100/100 on the first two assignments - hello world and some other bizarre application that displays different text depending on which radiobutton and checkbox you pick. For my last four projects, I have taken considerable liberty with my programming. I've introduced things that aren't in the scope of the class ... things like GDI printing, structs, enums and <gasp> even data driven error control.

I find it to be laziness when programmers users rely on Try/Catch blocks to prevent invalid data from being entered.

The textbook says to use a Try/Catch block to prevent a user from entering text in a numeric textbox. I prefer to simply find out if the text is numeric before I try to act on it ...
Why would I use
Code: [Select]
Try
  ThisVar = Cint(TextBox1.Text)
Catch ex As Exception
  MsgBox(e.Message)
End Try

When this will give a better result and allow you to filter stuff as you go.

Code: [Select]
If IsNumeric(TextBox1.Text) Then
  ThisVar = Cint(TextBox1.Text)
Else
  MsgBox("TextBox1 can contain only numbers")
End If

Maybe it is just me, but I hate like hell seeing those errors line up in the immediate window ..
Heck, I even use Option Strict and treat all warnings as errors ... in the end, the code is much more stable.

Oh well, such is life.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

pkohut

  • Bull Frog
  • Posts: 483
Re: My first programming exercise for college
« Reply #40 on: February 09, 2011, 01:08:13 AM »
Well Keith, have to agree with the book on this one. Since CInt throws an error, it makes sense to use the try catch block. It's by design. Also, the approach you suggest doubles the work load if the value is numeric, by first checking, then converting. If the input data needs validation between a range, then try/catch/finally is the proper solution.
New tread (not retired) - public repo at https://github.com/pkohut

dan.glassman

  • Guest
Re: My first programming exercise for college
« Reply #41 on: February 09, 2011, 09:26:20 AM »
Your code contains a bug.  Enter "2,147,483,648" into the TextBox, and you should get an OverflowException.

It may also be a bug because the value of the TextBox isn't under your sole control, and may change between the If and the CInt.  I'm not sure if that's true in this case, but this (for example) would definitely be a bug:

if (File.Exists(f))
   File.Open(f)



-drg

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: My first programming exercise for college
« Reply #42 on: February 09, 2011, 09:41:19 AM »
Well Keith, have to agree with the book on this one. Since CInt throws an error, it makes sense to use the try catch block. It's by design. Also, the approach you suggest doubles the work load if the value is numeric, by first checking, then converting. If the input data needs validation between a range, then try/catch/finally is the proper solution.


We will have to agree to disagree here ... the workload is doubled on the programmer perhaps in writing code, but the processor workload is negligibly impacted by the extra call to IsNumeric.

Using that logic, it would be ok to use a loop and then a "On Error Resume Next" simply because .. well, it must not be what we wanted so lets just ignore it.

Your code contains a bug.  Enter "2,147,483,648" into the TextBox, and you should get an OverflowException.

It may also be a bug because the value of the TextBox isn't under your sole control, and may change between the If and the CInt.  I'm not sure if that's true in this case, but this (for example) would definitely be a bug:

if (File.Exists(f))
   File.Open(f)



-drg

It doesn't when the box is limited to 5 characters ... its all about design. Understand what can be entered and then you can understand the minimum code needed to handle it.

Incidently the text actually insists that all numbers are parsed using the Parse method of the expected type ... whether that is Decimal, Integer, Double or Long ..
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: My first programming exercise for college
« Reply #43 on: February 09, 2011, 10:04:58 AM »

pkohut

  • Bull Frog
  • Posts: 483
Re: My first programming exercise for college
« Reply #44 on: February 09, 2011, 10:17:27 AM »
Well Keith, have to agree with the book on this one. Since CInt throws an error, it makes sense to use the try catch block. It's by design. Also, the approach you suggest doubles the work load if the value is numeric, by first checking, then converting. If the input data needs validation between a range, then try/catch/finally is the proper solution.


We will have to agree to disagree here ... the workload is doubled on the programmer perhaps in writing code, but the processor workload is negligibly impacted by the extra call to IsNumeric.
More along the lines of don't have redundant code. In the provided example, try/catch is the proper way to convert the input to an int. Why fight the language and API?


New tread (not retired) - public repo at https://github.com/pkohut