Pastebins are at the end of the log.
[2009/03/12 13:00] Adelle Fitzgerald: hi Snowdrop :)
[2009/03/12 13:00] Snowdrop Short: hi Adelle
[2009/03/12 13:00] Snowdrop Short: how are you today?
[2009/03/12 13:00] Adelle Fitzgerald: how are ya hehe
[2009/03/12 13:00] Adelle Fitzgerald: im good thanks, you?
[2009/03/12 13:00] Snowdrop Short: pretty good thank you, a bit tired
[2009/03/12 13:01] Snowdrop Short: I have been outdoors most of the
day
[2009/03/12 13:01] Adelle Fitzgerald: ahh
[2009/03/12 13:01] Snowdrop Short: getting the garden ready for
spring
[2009/03/12 13:01] Adelle Fitzgerald: cool :)
[2009/03/12 13:01] M1sha Dallin: Hi all
[2009/03/12 13:01] Snowdrop Short: hi M1sha
[2009/03/12 13:01] Starky Rubble: howdy
[2009/03/12 13:01] Snowdrop Short: hi Starky
[2009/03/12 13:01] Adelle Fitzgerald: hi Starky, M1sha :)
[2009/03/12 13:02] Snowdrop Short: I saw you message on IRC, but I
was afk
[2009/03/12 13:02] Starky Rubble: oh well
[2009/03/12 13:02] Snowdrop Short: how did the homework asignment go?
[2009/03/12 13:02] Snowdrop Short: assignment, even
[2009/03/12 13:02] Starky Rubble: I ammissing something fundemental
but we'll get there in time
[2009/03/12 13:03] Snowdrop Short: hi Marcus
[2009/03/12 13:03] Marcus Llewellyn: Hellos
[2009/03/12 13:03] Adelle Fitzgerald: hi Marcus
[2009/03/12 13:03] M1sha Dallin: I didn't - started looking at other
things
[2009/03/12 13:03] M1sha Dallin: Hi Marcus
[2009/03/12 13:03] Marcus Llewellyn smiles. :)
[2009/03/12 13:03] Starky Rubble: I did it by virtue of a hard head
and a not too thick wall lol :
http://www.pastebin.ca/1359316
[2009/03/12 13:03] Adelle Fitzgerald: oh homework, i actually
completed it ok this time :)
[2009/03/12 13:04] Adelle Fitzgerald: just pastebinning now
[2009/03/12 13:04] Starky Rubble: its stoopid ugly tho
[2009/03/12 13:04] Starky Rubble: but hey it works
[2009/03/12 13:04] Marcus Llewellyn:
http://pastebin.ca/1359318
[2009/03/12 13:04] Adelle Fitzgerald:
http://www.pastebin.ca/1359319
[2009/03/12 13:05] Snowdrop Short: if it works, then your are more
than half way there
[2009/03/12 13:05] Adelle Fitzgerald: Marcus, you beat me to pastebin
by 1 :P
[2009/03/12 13:05] Marcus Llewellyn: lol
[2009/03/12 13:07] Snowdrop Short smiles
[2009/03/12 13:07] Snowdrop Short: three different solutions
[2009/03/12 13:07] Adelle Fitzgerald: the only thing with mine, is i
couldnt trap the input for the operand at the time of input to make
sure it was correct, so I did that when it performed the calculation
[2009/03/12 13:07] Snowdrop Short: but all of them seems to be doing
the job
[2009/03/12 13:07] Adelle Fitzgerald: at first i tried using strings
for the operand, but didnt work
[2009/03/12 13:08] Adelle Fitzgerald: so i researched it and found
other code, so i feel i cheated a little
[2009/03/12 13:08] Adelle Fitzgerald: but...
[2009/03/12 13:08] Snowdrop Short: google is your friend
[2009/03/12 13:08] Adelle Fitzgerald: i didnt copy the code, only the
switch/case bit
[2009/03/12 13:08] Snowdrop Short: I don't know how code was written
before google was invented
[2009/03/12 13:08] Marcus Llewellyn: lol
[2009/03/12 13:09] Marcus Llewellyn: Over and over again. lol
[2009/03/12 13:09] Adelle Fitzgerald: i did try looking on msdn, but
that just blew me away
[2009/03/12 13:09] Starky Rubble: we shared floppies
[2009/03/12 13:09] Adelle Fitzgerald: lol
[2009/03/12 13:09] M1sha Dallin: plagiarism is the sincerest form of
flattery :-)
[2009/03/12 13:09] Adelle Fitzgerald: that sounds rude starky!
[2009/03/12 13:09] Snowdrop Short: the three virtues of programmer
[2009/03/12 13:09] Snowdrop Short: lazyness, hubris and stubborness
[2009/03/12 13:10] Snowdrop Short: lazyness: I'm just going to reuse
this code
[2009/03/12 13:10] Snowdrop Short: hubris: I know this can be done
[2009/03/12 13:10] Snowdrop Short: stubborness: I'm not leaving the
computer until this works
[2009/03/12 13:10] Adelle Fitzgerald: lol
[2009/03/12 13:11] M1sha Dallin: :-)
[2009/03/12 13:11] Adelle Fitzgerald: i know all three all to well
form LSL scripting
[2009/03/12 13:11] Marcus Llewellyn: Yay for caffeine!
[2009/03/12 13:11] Adelle Fitzgerald: *from
[2009/03/12 13:11] Snowdrop Short: if you sometimes think like that,
then you have much of what it takes
[2009/03/12 13:12] Adelle Fitzgerald: i do, thats how i work with
LSL, ive kinda grown into it
[2009/03/12 13:12] Adelle Fitzgerald: ive had some scripts that have
taken hours to complete, but never defeated
[2009/03/12 13:13] Adelle Fitzgerald: and for lazyness, i even
thought of making samples of things that i can just copy and paste
from, so i dont have to go digging into other scripts to find the
bits, ive just been too lazy to do that
[2009/03/12 13:13] Starky Rubble: heh
[2009/03/12 13:13] Adelle Fitzgerald: but anyway, back to C# :)
[2009/03/12 13:14] Snowdrop Short nods, most modern code editors have
a framework for code snippets
[2009/03/12 13:14] Marcus Llewellyn: I used to spend a lot of time
making my own code library. the .NET framework makes that sort of
thing largely unnecessary now.
[2009/03/12 13:14] Starky Rubble: the thing is... if you have
favorite bits in C# you get to build a library and *use* it
[2009/03/12 13:14] Snowdrop Short: yes, the framework takes that
away, so you can work on the important stuff rather than plumbing
[2009/03/12 13:14] Adelle Fitzgerald: right Starky :)
[2009/03/12 13:15] Starky Rubble: funny, that last intechange...
[2009/03/12 13:16] Starky Rubble: my problem is that I have tried
several times (more than 10) to move repetitive code into a class...
so far without success
[2009/03/12 13:16] Starky Rubble: and i don't have a clue
[2009/03/12 13:16] Snowdrop Short: somethings cannot easily be reused
that way
[2009/03/12 13:17] Starky Rubble: leyes but this example was
conceptually doab;
[2009/03/12 13:17] Starky Rubble: doable
[2009/03/12 13:17] M1sha Dallin: object code can generally -
functional is more difficult - a different way of thinking
[2009/03/12 13:17] Snowdrop Short: two different thought processes
[2009/03/12 13:18] Starky Rubble: yes but it is syntax I imagine -
something I didn't get/don't see or whatever
[2009/03/12 13:19] Starky Rubble: I get weird unhelpful errors in the
constructor every time
[2009/03/12 13:19] Snowdrop Short: when you first start out doing OO
programming, and you are used to functional thinking, you tend not to
use objects and classes in the most efficient way
[2009/03/12 13:19] M1sha Dallin: more design I think - you can write
C# as if it was C
[2009/03/12 13:19] Starky Rubble: I just did lol
[2009/03/12 13:19] Marcus Llewellyn: Hellom kidd. :)
[2009/03/12 13:19] Adelle Fitzgerald: hi kidd
[2009/03/12 13:19] Snowdrop Short: hiya Kidd
[2009/03/12 13:20] Marcus Llewellyn: I was a VB programmer. That
language started out functional, and later become object oriented. I
avoided OO for quite a while.
[2009/03/12 13:20] Snowdrop Short nods
[2009/03/12 13:20] Snowdrop Short: VB before the days of
VB.NET was
"only" sort of object oriented
[2009/03/12 13:20] Marcus Llewellyn: It lacked a lot of features, and
those it did have was... quirky, to be kind. lol
[2009/03/12 13:21] Starky Rubble: it was hot in its day to be fair
[2009/03/12 13:21] Snowdrop Short: actually the
VB.NET is almost
identical to C#
[2009/03/12 13:21] Starky Rubble: yep
[2009/03/12 13:21] Snowdrop Short: in what you can do with it
[2009/03/12 13:22] Snowdrop Short: I consider
VB.NET to be a huge
improvement over traditional VB
[2009/03/12 13:22] Starky Rubble: its based on the same code isn't
it?
[2009/03/12 13:22] Marcus Llewellyn: Yeah, but C# really is the more
mainstream language now. VB has a very legacy feel anymore.
[2009/03/12 13:22] Starky Rubble: right
[2009/03/12 13:22] Snowdrop Short: true
[2009/03/12 13:22] Snowdrop Short: so lets focus on c#
[2009/03/12 13:22] Marcus Llewellyn: hehe
[2009/03/12 13:22] Starky Rubble: good
[2009/03/12 13:23] Snowdrop Short: if you look at the three programs
you made
[2009/03/12 13:23] Snowdrop Short: wb M1sha
[2009/03/12 13:23] M1sha Dallin: ty :-)
[2009/03/12 13:23] Sit: e97cf410-8e61-7005-ec06-629eba4cd1fb
[2009/03/12 13:23] Marcus Llewellyn: That one's borked. :P
[2009/03/12 13:23] M1sha Dallin: yep
[2009/03/12 13:24] Adelle Fitzgerald: hey BlueWall
[2009/03/12 13:24] BlueWall Slade needs to overhaol the sitting
scripts
[2009/03/12 13:24] BlueWall Slade: Hey
[2009/03/12 13:24] Snowdrop Short: weird
[2009/03/12 13:24] Snowdrop Short: I just lost all internet
connectivity
[2009/03/12 13:24] Marcus Llewellyn: ack
[2009/03/12 13:24] Snowdrop Short: but didn't loose connection to the
grid
[2009/03/12 13:25] Snowdrop Short: and now I'm back
[2009/03/12 13:25] M1sha Dallin: even stranger
[2009/03/12 13:25] Marcus Llewellyn: UDP for the win. lol
[2009/03/12 13:25] BlueWall Slade: hehe
[2009/03/12 13:25] Adelle Fitzgerald: haha
[2009/03/12 13:25] Snowdrop Short: all of them are different
[2009/03/12 13:25] Snowdrop Short: and I think we can learn a bit by
looking at them
[2009/03/12 13:26] Snowdrop Short: so we could either do a review of
them, or we could move forward from where we are now
[2009/03/12 13:26] Snowdrop Short: what would you prefer?
[2009/03/12 13:26] Starky Rubble: review
[2009/03/12 13:26] Adelle Fitzgerald: ill go with that
[2009/03/12 13:26] Marcus Llewellyn: I wouldn't mind a critique.
[2009/03/12 13:26] Snowdrop Short: ok
[2009/03/12 13:26] Snowdrop Short: so lets do them in sequence
[2009/03/12 13:26] Snowdrop Short: we start with Starky's
[2009/03/12 13:27] Snowdrop Short: we have one big Main, which does
everything
[2009/03/12 13:27] Snowdrop Short: which is ok, it works
[2009/03/12 13:28] Snowdrop Short: but generally, unless there is a
good reason not to, any method shouldn't have more than 15-20 lines of
code at the most
[2009/03/12 13:28] Starky Rubble: ok
[2009/03/12 13:29] Snowdrop Short: ideally you should be able to read
everything in the method on the screen, without scrolling
[2009/03/12 13:29] Snowdrop Short: but it works
[2009/03/12 13:29] Snowdrop Short: and that is the important thing
[2009/03/12 13:29] Snowdrop Short: once it works, you can worry about
making it prettier
[2009/03/12 13:29] BlueWall Slade: whew OS isn't "ideal"
[2009/03/12 13:29] Marcus Llewellyn: hehe
[2009/03/12 13:30] Snowdrop Short: I agree, I have seen some horrors
in there
[2009/03/12 13:30] Snowdrop Short: especially in scenegraph
[2009/03/12 13:30] Marcus Llewellyn: I'll file a mantis. "Code
methods don't fit on one screen."
[2009/03/12 13:30] Starky Rubble: I have many others that are
'shapelier' but don't work lol
[2009/03/12 13:30] Adelle Fitzgerald: lol Marcus!
[2009/03/12 13:30] Snowdrop Short smiles
[2009/03/12 13:31] Snowdrop Short: it is alpha, so it is ok
[2009/03/12 13:31] BlueWall Slade: otoh, that accounts for the layers
and layers of things too
[2009/03/12 13:31] Marcus Llewellyn: hehehe
[2009/03/12 13:31] BlueWall Slade: so it's a trade-off?
[2009/03/12 13:31] Starky Rubble: yes
[2009/03/12 13:31] Snowdrop Short: well the important thing is to get
things to work, and then make it better
[2009/03/12 13:31] Snowdrop Short: OpenSim is still in the stage of
"making it work"
[2009/03/12 13:31] BlueWall Slade: hehe, we have a long road to
travel
[2009/03/12 13:32] Snowdrop Short: next you have a do ... while loop
[2009/03/12 13:33] Snowdrop Short: which means that it will loop as
long as the while condition at the end is true
[2009/03/12 13:34] Snowdrop Short: the more common version of that is
"while(<codition>) { <code> }
[2009/03/12 13:34] Starky Rubble: does everybody have the pastebins?
[2009/03/12 13:34] Marcus Llewellyn: I do.
[2009/03/12 13:34] M1sha Dallin: yep
[2009/03/12 13:34] Snowdrop Short:
http://www.pastebin.ca/1359316
[2009/03/12 13:34] Snowdrop Short: if not
[2009/03/12 13:34] Snowdrop Short: here it is
[2009/03/12 13:35] Starky Rubble: really i could have just reversed
that logic easily
[2009/03/12 13:35] Snowdrop Short: yes, most of the time, you can
reverse the logic pretty easily
[2009/03/12 13:36] Snowdrop Short: and while do, has one advantage
over do while
[2009/03/12 13:36] Starky Rubble: it came from my english written
version lol
[2009/03/12 13:36] Snowdrop Short: you meet the condition for the
loop, early on when reading it
[2009/03/12 13:36] Starky Rubble: it skips the block
[2009/03/12 13:36] Snowdrop Short: when you encounter a "do"
[2009/03/12 13:37] Snowdrop Short: most of the time, people will
immediately look further down in the code, to find the while
[2009/03/12 13:37] Snowdrop Short: in order to understand for how
long the loop will continue
[2009/03/12 13:37] Starky Rubble: right I should have commented it in
[2009/03/12 13:37] Starky Rubble: at the top
[2009/03/12 13:37] Snowdrop Short: by having the while in top, you
don't have to scroll
[2009/03/12 13:38] Starky Rubble: OTOH I wanted to do the code once
no matter what
[2009/03/12 13:38] Snowdrop Short: yes, an that's usually why you go
for a do while, rather than a while do
[2009/03/12 13:39] Snowdrop Short: the do while will always execute
the code once, regardless of the condition
[2009/03/12 13:40] Snowdrop Short: next you adopted and modified the
code for reading input and converting it to an integer
[2009/03/12 13:40] Snowdrop Short: allowing for "Q" or "q"
[2009/03/12 13:40] Snowdrop Short: I like that you have decided to go
for both upper and lower case
[2009/03/12 13:40] Starky Rubble: so painful but I didn't get YoUpper
to work there
[2009/03/12 13:40] Snowdrop Short: it makes it more user friendly
[2009/03/12 13:40] Starky Rubble: ToUpper
[2009/03/12 13:41] Marcus Llewellyn: I was wondering why you didn't
convert to a single case.
[2009/03/12 13:41] Snowdrop Short: did you try str1.ToUpper() == "Q"
[2009/03/12 13:41] Starky Rubble: str1 = str1.ToUpper? nah...
[2009/03/12 13:41] Starky Rubble: no
[2009/03/12 13:42] Snowdrop Short: I think str1.ToUpper() would have
worked
[2009/03/12 13:42] Snowdrop Short: there is one thing about the while
codition though
[2009/03/12 13:42] Snowdrop Short: you are using &
[2009/03/12 13:42] Starky Rubble: i used != of course but I think it
errored
[2009/03/12 13:42] Snowdrop Short: and not "&&"
[2009/03/12 13:43] Snowdrop Short: there is a slight difference
[2009/03/12 13:43] Starky Rubble: oh that may be why
[2009/03/12 13:43] Snowdrop Short: which could, have a big influence
[2009/03/12 13:44] Snowdrop Short: & means "logical and"
[2009/03/12 13:44] Snowdrop Short: && means "boolean and"
[2009/03/12 13:44] Snowdrop Short: & | are used when working with
individual bits
[2009/03/12 13:44] Snowdrop Short: and && || are used with conditions
[2009/03/12 13:44] Snowdrop Short: which can either be true or false
[2009/03/12 13:45] Starky Rubble: right
[2009/03/12 13:45] Marcus Llewellyn: Basically, once performs an
operation, while the other just compares, right?
[2009/03/12 13:45] Starky Rubble: yes
[2009/03/12 13:45] Snowdrop Short: hold on ..
[2009/03/12 13:46] Snowdrop Short: hmm
[2009/03/12 13:47] Starky Rubble: it says != cannot be appllied to
operands of type 'method group' or string
[2009/03/12 13:47] Snowdrop Short: asdfas
[2009/03/12 13:47] Snowdrop Short: my internet is a bit unstable
tonight it seems
[2009/03/12 13:47] Marcus Llewellyn: :(
[2009/03/12 13:47] Starky Rubble: ow
[2009/03/12 13:48] Snowdrop Short: lets say you have an integer
[2009/03/12 13:48] Snowdrop Short: which really is a bit map
[2009/03/12 13:48] Snowdrop Short: so 1 means "Passport ok"
[2009/03/12 13:49] Snowdrop Short: and 2 means "Visa ok"
[2009/03/12 13:49] Snowdrop Short: and 4 means "has foreign currency"
[2009/03/12 13:49] M1sha Dallin: Is there an enumeration type in C#?
[2009/03/12 13:49] Starky Rubble: you can AND or OR them together
[2009/03/12 13:49] Snowdrop Short: then the number 5 would mean
"Passport ok and has foreign currency"
[2009/03/12 13:50] Starky Rubble: right
[2009/03/12 13:50] Snowdrop Short: yes, there is, a pretty good one
to boot :(
[2009/03/12 13:50] Snowdrop Short: :-), even
[2009/03/12 13:50] M1sha Dallin: ok - and sets?
[2009/03/12 13:50] Snowdrop Short: both a "set" collection and enums
which can work as sets
[2009/03/12 13:51] Snowdrop Short: lets say you have a status
variable, about a user, containing one or more of the values
[2009/03/12 13:51] Snowdrop Short: e.g. 6
[2009/03/12 13:51] Snowdrop Short: meaning "visa ok and has foreign
currency"
[2009/03/12 13:51] Starky Rubble: rich and good credit lol
[2009/03/12 13:51] Marcus Llewellyn: hehe
[2009/03/12 13:52] Snowdrop Short: then you could have a condition
like this one:
[2009/03/12 13:52] Snowdrop Short: status & 2 == 0
[2009/03/12 13:52] Snowdrop Short: which would be false in this
situation, because the "two" bit would be "on"
[2009/03/12 13:53] Snowdrop Short: so status & 2 would actually be
"2"
[2009/03/12 13:53] Starky Rubble: right
[2009/03/12 13:53] Snowdrop Short: it is often used to put a lot of
information into one single integer
[2009/03/12 13:54] Snowdrop Short: or byte, in order to save space
[2009/03/12 13:54] Starky Rubble: i did so last assignment
[2009/03/12 13:54] Marcus Llewellyn smiles. :)
[2009/03/12 13:54] Starky Rubble: its elegant too IMHO
[2009/03/12 13:54] Marcus Llewellyn agrees.
[2009/03/12 13:54] Snowdrop Short nods, but maybe not everybody here,
understands bitmaps
[2009/03/12 13:54] Starky Rubble: ahh of couse
[2009/03/12 13:55] Snowdrop Short: so the & and | operators works on
bits
[2009/03/12 13:55] Snowdrop Short: and && || works on conditions,
which are either true or false
[2009/03/12 13:55] Snowdrop Short: like a comparison
[2009/03/12 13:55] Snowdrop Short: str1 != "Q"
[2009/03/12 13:56] Snowdrop Short: or a boolean variable, which can
either be true or false also
[2009/03/12 13:56] Snowdrop Short: but there is a thing which is
important to understand
[2009/03/12 13:56] Snowdrop Short: about conditions
[2009/03/12 13:56] Snowdrop Short: I'll give you an example
[2009/03/12 13:57] Snowdrop Short: lets take a look at the str1 !=
"Q"
[2009/03/12 13:57] Snowdrop Short: it could have been written this
way str1[0] != 'Q'
[2009/03/12 13:58] Snowdrop Short: essentially I'm saying "is the
first character (counting from zero) equal to 'Q'"
[2009/03/12 13:58] Starky Rubble: right
[2009/03/12 13:58] Marcus Llewellyn: What would have been the
advantage to that in this case?
[2009/03/12 13:59] Snowdrop Short: hmm .. lost it again :-(
[2009/03/12 13:59] Snowdrop Short: and I lost what I tried to say
[2009/03/12 13:59] M1sha Dallin: a mistype by the user e.g. entering
Qw
[2009/03/12 13:59] Starky Rubble: why grab just the first char
[2009/03/12 14:00] Snowdrop Short: str1[0] refers to the first
character of str1, remember we count from zero
[2009/03/12 14:00] Starky Rubble: yep
[2009/03/12 14:00] Snowdrop Short: and 'Q' is a charcter constant,
just like "Q" is a string constant
[2009/03/12 14:00] Starky Rubble: yes
[2009/03/12 14:01] Snowdrop Short: strinks are made up of a ...
string ... of charcters :-)
[2009/03/12 14:01] Snowdrop Short: like beads on a chain
[2009/03/12 14:01] Marcus Llewellyn: IN essence, a specialized array.
[2009/03/12 14:01] Snowdrop Short: yes
[2009/03/12 14:01] Starky Rubble: yep
[2009/03/12 14:02] Adelle Fitzgerald: i never looked at them that way
[2009/03/12 14:02] Starky Rubble: thats why the [0] works
[2009/03/12 14:02] Snowdrop Short: but what happens if the user just
pressed enter
[2009/03/12 14:02] Snowdrop Short: without providing any input
[2009/03/12 14:02] Starky Rubble: ""
[2009/03/12 14:02] Snowdrop Short: then str1[0], would be illegal
[2009/03/12 14:03] Marcus Llewellyn: Ah... because there is no first
char to compare to.
[2009/03/12 14:03] Snowdrop Short nods
[2009/03/12 14:03] Snowdrop Short: I could handle that by writing
[2009/03/12 14:04] Snowdrop Short: if(str1.Length>0 && str1[0} !=
'Q')
[2009/03/12 14:04] Snowdrop Short: that would not generate an error
[2009/03/12 14:04] Snowdrop Short: because it uses something called
"short circuiting"
[2009/03/12 14:05] Snowdrop Short: the compiler know that if the
value on the left hand is false
[2009/03/12 14:05] Snowdrop Short: then the result of "false && xxxx"
will also be false
[2009/03/12 14:05] Snowdrop Short: regardless if xxx is true or false
[2009/03/12 14:05] Snowdrop Short: so it never executes the right
hand side
[2009/03/12 14:05] M1sha Dallin: Does it evaluate left to right?
[2009/03/12 14:06] Snowdrop Short: yes, from left to right
[2009/03/12 14:06] Snowdrop Short: always
[2009/03/12 14:06] Marcus Llewellyn: I tend to parenthesize those
sorta of statements, just to avoid trouble. Hehe
[2009/03/12 14:06] M1sha Dallin: Ada had an 'and then' to ensure it
was forced
[2009/03/12 14:06] Starky Rubble: heh
[2009/03/12 14:06] Starky Rubble: there is actually a table of order
of evaluation
[2009/03/12 14:07] Snowdrop Short: yes ..
[2009/03/12 14:07] Starky Rubble: of which this is the first entry
[2009/03/12 14:07] Snowdrop Short: and left to right is the general
rule when evaluating equally prioritized operators
[2009/03/12 14:07] M1sha Dallin: ok
[2009/03/12 14:08] Snowdrop Short: still looking at yoru while(!
int.TryPars......
[2009/03/12 14:08] Starky Rubble: ok so I\if I use &&, while (!
int.TryParse(str1, out num1) && ((str1.ToUpper != "Q") )) still
generatews that error
[2009/03/12 14:08] Marcus Llewellyn: Remeber the parenthesis?
str1.TpUpper()
[2009/03/12 14:08] Starky Rubble: ooooo
[2009/03/12 14:09] Starky Rubble: Now that was a helpful error
message lol
[2009/03/12 14:09] Marcus Llewellyn: lol
[2009/03/12 14:09] Snowdrop Short: while (!int.TryParse(str1, out
num1) & str1.ToUpper()!= "Q")
[2009/03/12 14:09] Snowdrop Short: it works for me
[2009/03/12 14:09] Starky Rubble: works fine
[2009/03/12 14:09] Starky Rubble: Marcus saw it
[2009/03/12 14:10] Starky Rubble: crap I spent way too long on that
[2009/03/12 14:10] Starky Rubble: heh
[2009/03/12 14:10] Adelle Fitzgerald: you learned something though :)
[2009/03/12 14:11] Adelle Fitzgerald: as i have done too
[2009/03/12 14:11] Snowdrop Short: but now you probably remember it
better
[2009/03/12 14:11] Marcus Llewellyn: Makin keywords and syntax
habitual is half the battle. :P
[2009/03/12 14:11] Starky Rubble: lets hope (he said pounding it in)
[2009/03/12 14:11] Adelle Fitzgerald: hehe
[2009/03/12 14:11] Snowdrop Short: ((str2 != "Q") & (str2 != "q"))
[2009/03/12 14:11] Adelle Fitzgerald: personally, i prefer ToLower()
the initial string
[2009/03/12 14:11] Marcus Llewellyn: I do the same, adelle. Hehe.
[2009/03/12 14:12] Snowdrop Short: you have too many parenthesis
compared to what you need
[2009/03/12 14:12] Snowdrop Short: but it is considered good form to
use enough parenthesis to make things clear
[2009/03/12 14:12] Snowdrop Short: not everybody remembers the exact
operator precedense
[2009/03/12 14:13] Snowdrop Short: so it is better to have too many,
than too few
[2009/03/12 14:13] Snowdrop Short: and then having somebody less
experieced wonder if it is right
[2009/03/12 14:13] Starky Rubble: they're free after all
[2009/03/12 14:13] Marcus Llewellyn: hehe
[2009/03/12 14:14] Marcus Llewellyn: They're 10L each in SL. ;)
[2009/03/12 14:14] M1sha Dallin: :-)
[2009/03/12 14:14] Starky Rubble: haha
[2009/03/12 14:14] Starky Rubble: ok I have other similar &/&& errors
[2009/03/12 14:15] Starky Rubble: and a couple of while loops but the
other novelty ids the goto
[2009/03/12 14:15] Snowdrop Short: next you nest an if, in order to
not continue, if the user entered Q
[2009/03/12 14:15] Starky Rubble: oh ok
[2009/03/12 14:15] Snowdrop Short: you could have written it like
this
[2009/03/12 14:15] Snowdrop Short: and had the same result
[2009/03/12 14:16] Snowdrop Short: f ((str2 == "Q") ||(str2 == "q"))
break;
[2009/03/12 14:16] Snowdrop Short: break, when it is used outside a
"case" statement, breaks out of the current loop
[2009/03/12 14:17] Starky Rubble: ok
[2009/03/12 14:17] Starky Rubble: how would you just end the program
[2009/03/12 14:17] Snowdrop Short: so that "break" would have broken
you out of the do/while loop
[2009/03/12 14:17] Starky Rubble: dropped through
[2009/03/12 14:18] Snowdrop Short: in some projects, having a nexting
level deeper than 4 is a no no
[2009/03/12 14:18] Snowdrop Short: in other projects it is ok
[2009/03/12 14:19] Snowdrop Short: then you have the same logic
again, for the second number
[2009/03/12 14:19] Starky Rubble: repition
[2009/03/12 14:19] Snowdrop Short: the word "again" .. hints that
maybe you could have used a separate method for doing that
[2009/03/12 14:19] Snowdrop Short: remember "DRY"
[2009/03/12 14:19] Starky Rubble: yep
[2009/03/12 14:20] Snowdrop Short: "Do Not Repeat yourself"
[2009/03/12 14:20] Snowdrop Short: because if you need to change
something, then you need to change it several places
[2009/03/12 14:20] Snowdrop Short: and there is a good chance you
overlook one of the places, and introduce a bug
[2009/03/12 14:20] Snowdrop Short: but remember
[2009/03/12 14:20] Starky Rubble: right
[2009/03/12 14:21] Snowdrop Short: all of what I'm saying is just
suggestions
[2009/03/12 14:21] Snowdrop Short: what you made works, it does the
job
[2009/03/12 14:21] Snowdrop Short: and that's the important thing
[2009/03/12 14:21] Starky Rubble: I wanted to do the above lol
[2009/03/12 14:21] Snowdrop Short: so please don't take it a
critisim, merely suggestions on other ways to do it
[2009/03/12 14:21] Snowdrop Short: in c#
[2009/03/12 14:22] Snowdrop Short: next you do pretty much the same
thing, for the operation
[2009/03/12 14:22] Snowdrop Short: and finally a switch/case
[2009/03/12 14:23] Snowdrop Short: for dealing with "+" and "-" and
"q"
[2009/03/12 14:23] Starky Rubble: or if weird stuff happened,
anything else
[2009/03/12 14:23] Snowdrop Short nods
[2009/03/12 14:24] Snowdrop Short: defensive programming
[2009/03/12 14:24] Snowdrop Short: if something weird happens you
don't crash
[2009/03/12 14:24] Snowdrop Short: some people think "defensive
programming" is a must
[2009/03/12 14:25] Snowdrop Short: others ... well, they like a rude
awakening if something is wrong
[2009/03/12 14:25] Snowdrop Short: no to the oddity
[2009/03/12 14:25] Snowdrop Short: the goto statement
[2009/03/12 14:25] Snowdrop Short: well before that
[2009/03/12 14:25] Snowdrop Short: you actually had a differet option
[2009/03/12 14:26] Snowdrop Short: you could have written
[2009/03/12 14:26] Snowdrop Short: case "Q":
[2009/03/12 14:26] Snowdrop Short: case "q":
[2009/03/12 14:26] Snowdrop Short: goto default;
[2009/03/12 14:27] Adelle Fitzgerald: hiya Tiffany :)
[2009/03/12 14:27] Tiffany Sicling: hiyas
[2009/03/12 14:27] Snowdrop Short: that would have told the reader of
the program that you intended for Q to be treated like the weird cases
[2009/03/12 14:27] Snowdrop Short: hiya Tiffany
[2009/03/12 14:27] Snowdrop Short: goto
[2009/03/12 14:27] Marcus Llewellyn: bleh
[2009/03/12 14:27] M1sha Dallin: :-)
[2009/03/12 14:27] Snowdrop Short: can really stirr up some religious
debates
[2009/03/12 14:27] Starky Rubble: ok
[2009/03/12 14:27] Starky Rubble: Yes, I used to use a "Cant ever get
here" default bucket with info as to where 'here' is
[2009/03/12 14:28] Starky Rubble: to handle 'weird' stuff
[2009/03/12 14:28] Starky Rubble: everything else was explicit
[2009/03/12 14:28] Starky Rubble: so thats better
[2009/03/12 14:28] Snowdrop Short: my personal opinion is that in
some situations, goto can be a valuable tool, especially in error
handling
[2009/03/12 14:29] Snowdrop Short: but somepeople think that any
language having a goto statment is miss designed
[2009/03/12 14:29] Starky Rubble: I winced when I used it lol
[2009/03/12 14:29] Marcus Llewellyn: I don't think it's an evil
feature, but I do treat it as a last resort, personally.
[2009/03/12 14:29] Snowdrop Short: and that any programmer using
"goto" really deserves to be shot
[2009/03/12 14:29] Starky Rubble: oh good!
[2009/03/12 14:29] Adelle Fitzgerald chuckles
[2009/03/12 14:30] Starky Rubble: phew
[2009/03/12 14:30] Snowdrop Short: sometimes it can make your cleanup
after an error a lot easier
[2009/03/12 14:30] Starky Rubble: it looked like it was only for use
in switch/case?
[2009/03/12 14:31] Snowdrop Short: but, be prepared to recieve some
questions when you use it
[2009/03/12 14:31] Starky Rubble: hehe
[2009/03/12 14:31] Snowdrop Short: there is a special use of goto in
switch/case statements
[2009/03/12 14:31] Starky Rubble: oh
[2009/03/12 14:31] Snowdrop Short: you could actually use statements
like
[2009/03/12 14:31] Snowdrop Short: case "q":
[2009/03/12 14:32] Snowdrop Short: goto "+";
[2009/03/12 14:32] Marcus Llewellyn: Nifty
[2009/03/12 14:32] Starky Rubble: ok
[2009/03/12 14:32] Starky Rubble: I wanted that ending message no
matter what
[2009/03/12 14:33] Starky Rubble: what would you have done?
[2009/03/12 14:33] Snowdrop Short: if you had taken care of "q" the
same way you did with num1 and num2
[2009/03/12 14:33] Snowdrop Short: instead of using the switch
statement, you could have had one more nesting level
[2009/03/12 14:34] Snowdrop Short: or one more
[2009/03/12 14:34] Snowdrop Short: break statement
[2009/03/12 14:34] Snowdrop Short: depending on the mood
[2009/03/12 14:34] Starky Rubble: right
[2009/03/12 14:34] Snowdrop Short: ohh by the way, some purists, but
not nearly as many as with goto, thinks that break is just as bad as
goto
[2009/03/12 14:34] Starky Rubble: ok
[2009/03/12 14:35] Marcus Llewellyn: They prefer return, I presume?
[2009/03/12 14:36] Snowdrop Short: one more pause in my internet
connection
[2009/03/12 14:36] Snowdrop Short: they prefer setting the "exitFlag"
to the terminating condition
[2009/03/12 14:36] Snowdrop Short: they prefer setting the "exitFlag"
to the terminating condition
[2009/03/12 14:36] Marcus Llewellyn: Oh, I see.
[2009/03/12 14:36] Snowdrop Short: and then using "if's" to control
execution inside the loop
[2009/03/12 14:36] Starky Rubble: right
[2009/03/12 14:37] Snowdrop Short: personally, I think they make life
way to complicated
[2009/03/12 14:37] Starky Rubble: there would be lots of ifs to fall
through
[2009/03/12 14:38] Adelle Fitzgerald: what is bad about using 'break'
though? does it leave used up memory or something?
[2009/03/12 14:38] Snowdrop Short: but, it is really religion
[2009/03/12 14:38] Starky Rubble: style
[2009/03/12 14:38] Snowdrop Short: they argue
[2009/03/12 14:38] Snowdrop Short: that you break out of the logic of
the loop rather than follow the flow
[2009/03/12 14:39] Starky Rubble: right
[2009/03/12 14:39] Adelle Fitzgerald: gotcha
[2009/03/12 14:39] Snowdrop Short: and since you break the flow
abruptly, it really is very similar to goto
[2009/03/12 14:39] Snowdrop Short: just with a different name
[2009/03/12 14:39] Marcus Llewellyn: dunno. Seems to me if the loop
in longer useful, just leave it. Heh.
[2009/03/12 14:39] Marcus Llewellyn: no longer*
[2009/03/12 14:39] Starky Rubble: and one goto is the first step on
the slippery slope to old style spagetti code lol
[2009/03/12 14:39] Snowdrop Short: that's my point of view also
[2009/03/12 14:40] Tiffany Sicling: goto reminds me of BASIC
[2009/03/12 14:40] Snowdrop Short: almost all programming languages
has a goto, or something similar
[2009/03/12 14:40] Snowdrop Short: I cannot think of a language,
which doesn't
[2009/03/12 14:40] Marcus Llewellyn: IN very old BASIC, goto was
essential, that and gosub. It was such a linear language.
[2009/03/12 14:41] Adelle Fitzgerald: and..... poke and peek!!! hehe
[2009/03/12 14:41] Tiffany Sicling: yuk, I hated it
[2009/03/12 14:41] Marcus Llewellyn: lol
[2009/03/12 14:41] Adelle Fitzgerald: i loved it!
[2009/03/12 14:41] kidd piko: memories ;)
[2009/03/12 14:41] Snowdrop Short: and then you have your nice exit
message
[2009/03/12 14:41] Starky Rubble: like assembler
[2009/03/12 14:42] Adelle Fitzgerald: one thing I have gotten form
your code Starky, is lots of little snippets of code that I am sure to
use in other things
[2009/03/12 14:42] Adelle Fitzgerald: *from
[2009/03/12 14:42] Adelle Fitzgerald: and please see that as a
compliment from me
[2009/03/12 14:42] Snowdrop Short: next lets looks at Marcus' code
[2009/03/12 14:42] Starky Rubble: :)
[2009/03/12 14:42] Snowdrop Short:
http://pastebin.ca/1359318
[2009/03/12 14:44] Snowdrop Short: again, we see the same logic for
reading input and converting to an integer
[2009/03/12 14:44] Snowdrop Short: execpt for the "WaitForIt" method
[2009/03/12 14:44] Snowdrop Short: that kind of threw me off on the
first read
[2009/03/12 14:44] Snowdrop Short: because I wondered what "it" was
[2009/03/12 14:45] Marcus Llewellyn: Sorry... a flippant name. :P
[2009/03/12 14:45] Snowdrop Short: putting the "press enter message"
into a separate method is a good thing
[2009/03/12 14:46] Snowdrop Short: but "WaitForEnterKey" would have
given me a clue as to what to expect
[2009/03/12 14:46] Snowdrop Short: I once overheard MW on IRC
[2009/03/12 14:46] Snowdrop Short: talking about how he'd given the
same thing different names for 2 days now, and still hadn't found a
good name
[2009/03/12 14:46] Marcus Llewellyn: Hehe
[2009/03/12 14:46] Snowdrop Short: finding good names is difficult,
but important
[2009/03/12 14:47] Marcus Llewellyn: Point well taken.
[2009/03/12 14:47] Snowdrop Short: because that makes the code a lot
easier to ready
[2009/03/12 14:47] Tiffany Sicling: pawz()
[2009/03/12 14:47] Marcus Llewellyn: lol
[2009/03/12 14:47] Snowdrop Short: too much unix time I think
[2009/03/12 14:48] Snowdrop Short: again, you could have made a
method for reading input, you have duplicated logice
[2009/03/12 14:48] Snowdrop Short: logice even
[2009/03/12 14:48] Snowdrop Short: but, I believe my original code
had the same problem
[2009/03/12 14:48] Marcus Llewellyn nods amiably.
[2009/03/12 14:49] Tiffany Sicling: Console.WriteLine("Please enter a
number:");
number1 = int.Parse(Console.ReadLine());
[2009/03/12 14:50] Snowdrop Short: Tiffany, yes, if you know that the
user entered an integer
[2009/03/12 14:50] Snowdrop Short: but if the user entered something
else, you get a runtime error
[2009/03/12 14:50] Tiffany Sicling: true
[2009/03/12 14:50] Snowdrop Short: TryParse is a bit more
complicated, but safer
[2009/03/12 14:51] Tiffany Sicling: int number1, number2;
[2009/03/12 14:51] Snowdrop Short: yes .. that's legal
[2009/03/12 14:51] Snowdrop Short: but why would you do it?
[2009/03/12 14:52] Starky Rubble: saved three keystokes
[2009/03/12 14:52] Marcus Llewellyn: I did that when I declared my
integers. Just seemed to look nice.
[2009/03/12 14:52] Snowdrop Short: it doesn't really matter
[2009/03/12 14:52] Snowdrop Short: there is no difference in the
resulting code
[2009/03/12 14:53] Starky Rubble: it could help you say wiyhin one
screen in a pinch lol
[2009/03/12 14:53] Marcus Llewellyn: Hehe
[2009/03/12 14:53] Snowdrop Short: if you decide to change the type
of number2, you have a little more work
[2009/03/12 14:53] Tiffany Sicling: string Idontknow="dunno";
[2009/03/12 14:54] Snowdrop Short: personally, I think the important
thing is that your code is easy to read
[2009/03/12 14:55] Snowdrop Short: but ... I'm not really happy with
the "Perform" method
[2009/03/12 14:55] Snowdrop Short: for two reasons
[2009/03/12 14:55] Snowdrop Short: but again, this is my personal
opinion
[2009/03/12 14:55] Snowdrop Short: the name is not that meaningfull
[2009/03/12 14:55] Snowdrop Short: perform ... what?
[2009/03/12 14:55] Marcus Llewellyn: Yes, you're right.
[2009/03/12 14:55] Snowdrop Short: wait for ... what?
[2009/03/12 14:56] Snowdrop Short: second ... it does two things
[2009/03/12 14:56] Tiffany Sicling: what about number1 = int.Parse
(input); ??
[2009/03/12 14:56] Snowdrop Short: personally I believe that a method
should do one thing, and one thing only
[2009/03/12 14:57] Snowdrop Short: input?
[2009/03/12 14:57] Marcus Llewellyn: Hmmm. Seemed more efficient to
kill two birds with one stone.
[2009/03/12 14:57] Snowdrop Short: but also more diffcult to read
[2009/03/12 14:57] Marcus Llewellyn: And honestly... we discuseed the
out in an keywords, and I wanted to play with it. lol
[2009/03/12 14:57] Snowdrop Short: so the name of the method should
be:
[2009/03/12 14:58] Tiffany Sicling: oh sorry, I didn't include input
= Console.ReadLine();
[2009/03/12 14:58] Snowdrop Short:
"PerformRequestedCalculationOnNumbersOrReturnFalseIfInvalid"
[2009/03/12 14:59] Adelle Fitzgerald: lol
[2009/03/12 14:59] Marcus Llewellyn: hehehe
[2009/03/12 14:59] Starky Rubble: nice
[2009/03/12 14:59] Snowdrop Short smiles
[2009/03/12 14:59] Tiffany Sicling: lol
[2009/03/12 14:59] Adelle Fitzgerald: and i bet purists would love
that!, but good point :)
[2009/03/12 14:59] Snowdrop Short: mabye one method which was called
"IsValidOperation(op)
[2009/03/12 15:00] Snowdrop Short: and then PerformCalculation(op,
num1, num2)
[2009/03/12 15:00] Marcus Llewellyn: See... that seems like duplicate
work to me. BUt I do understand where you are coming from from a
clairty point of view.
[2009/03/12 15:00] Snowdrop Short: the first method returns true or
false
[2009/03/12 15:01] Snowdrop Short: and the second the result of the
the operations
[2009/03/12 15:01] Snowdrop Short: then you could say:
[2009/03/12 15:01] Snowdrop Short: if(IsValidOperation(op)
resuls=PerformCalculation(op, num1, num2)
[2009/03/12 15:01] Snowdrop Short: forgive my missing parenthesis and
spelling
[2009/03/12 15:02] Snowdrop Short: but I hope you get my point
[2009/03/12 15:02] Marcus Llewellyn: Nods. Actually, you know the
real disadvantage to doing it like I did?
[2009/03/12 15:02] Snowdrop Short: I believe that would be more
understandable
[2009/03/12 15:02] Marcus Llewellyn: It prevented me from asking the
input questions in a more intuitive order....
[2009/03/12 15:02] Snowdrop Short tilts her head and listnes
[2009/03/12 15:02] Marcus Llewellyn: I had to ask for the operation
last.
[2009/03/12 15:03] Marcus Llewellyn: I knew that was a problem, but
like I said... I wanted to use that out keyword, so plowed ahead. heh
[2009/03/12 15:03] Snowdrop Short: all the others did it in the same
order
[2009/03/12 15:03] Marcus Llewellyn: True, but I would have prefered
not to, in a RL application.
[2009/03/12 15:03] Snowdrop Short: actually, wanting to try out the
"out" keyword is a good reason
[2009/03/12 15:04] Marcus Llewellyn: For class, yes. Hehe. BUt you
are correct in your critique, I feel.
[2009/03/12 15:04] Snowdrop Short: Tiffany: you still have a problem
if the user typed "help"
[2009/03/12 15:05] Starky Rubble: I wanted a more intuitive flow as
well
[2009/03/12 15:05] Starky Rubble: but sacrificed for expidiency
[2009/03/12 15:05] Snowdrop Short: ok .. but still, the most
important thing is to get it right
[2009/03/12 15:06] Snowdrop Short: ok .. now onto Adelle's
[2009/03/12 15:06] Snowdrop Short:
http://www.pastebin.ca/1359319
[2009/03/12 15:06] M1sha Dallin: I must go to bed at this point
[2009/03/12 15:06] M1sha Dallin: ty Snowdrop
[2009/03/12 15:06] Snowdrop Short: yes .. I'm going too slow :-(
[2009/03/12 15:06] Snowdrop Short: sorry about that
[2009/03/12 15:06] Starky Rubble: bye M1sha
[2009/03/12 15:06] Adelle Fitzgerald: night M1sha
[2009/03/12 15:06] M1sha Dallin: g'night all
[2009/03/12 15:06] Marcus Llewellyn: Sweet dreams, M1sha
[2009/03/12 15:06] Snowdrop Short: nini M1sha
[2009/03/12 15:06] kidd piko: cYa M1sha
[2009/03/12 15:07] Tiffany Sicling: nite m1sha
[2009/03/12 15:07] Tiffany Sicling: catch (FormatException e)
[2009/03/12 15:07] Snowdrop Short: ahh .... yes, that would do it
[2009/03/12 15:08] Snowdrop Short: depending on the use pattern you'd
expect from the user
[2009/03/12 15:08] Snowdrop Short: Adelle has the same logic for
reading input
[2009/03/12 15:08] Snowdrop Short: except that she reads the operator
in between the two numbers
[2009/03/12 15:09] Snowdrop Short: the "natural" order
[2009/03/12 15:09] Snowdrop Short: what is known as "infix notation"
[2009/03/12 15:09] Marcus Llewellyn smiles. :)
[2009/03/12 15:09] Starky Rubble: yep
[2009/03/12 15:09] Snowdrop Short: I'm not really happy about the
variable b in line 23
[2009/03/12 15:10] Snowdrop Short: I feel it should have been renamed
to C
[2009/03/12 15:10] Snowdrop Short: in order to match the string
[2009/03/12 15:10] Adelle Fitzgerald: yikes
[2009/03/12 15:10] Adelle Fitzgerald: yes agreed
[2009/03/12 15:10] Adelle Fitzgerald: was an error on my part
[2009/03/12 15:10] Snowdrop Short: but it works
[2009/03/12 15:10] Snowdrop Short: and again, we have a switch
statement
[2009/03/12 15:10] Adelle Fitzgerald: well not so much an error, but
lazyness, but now i see it... i didnt back then
[2009/03/12 15:11] Snowdrop Short: I haven't seen any real errors
[2009/03/12 15:11] Adelle Fitzgerald: i was reusing code, so made my
new code to fit the existing
[2009/03/12 15:11] Snowdrop Short: today
[2009/03/12 15:11] Snowdrop Short: only things I would have done
differently
[2009/03/12 15:12] Snowdrop Short: apart from that single thing
[2009/03/12 15:13] Snowdrop Short: I don't think there is much more
to say about this code
[2009/03/12 15:13] Snowdrop Short: it is pretty straight forward,
from point a to b
[2009/03/12 15:13] Snowdrop Short: I think that's it
[2009/03/12 15:14] Snowdrop Short: and it is getting late for me as
well
[2009/03/12 15:14] Adelle Fitzgerald nods
[2009/03/12 15:14] Starky Rubble: ok
[2009/03/12 15:14] Adelle Fitzgerald: ive learned a lot today
[2009/03/12 15:14] Starky Rubble: me too
[2009/03/12 15:14] Marcus Llewellyn smiles. :)
[2009/03/12 15:14] Snowdrop Short: then it was a good session
[2009/03/12 15:14] Starky Rubble: yes
[2009/03/12 15:14] Adelle Fitzgerald: from starky's snippets, marcus'
methods and my error
[2009/03/12 15:15] Tiffany Sicling: I wasn't aware of who or when C#
classes were
[2009/03/12 15:15] Snowdrop Short: not really an error
[2009/03/12 15:15] Adelle Fitzgerald: ok, but could have been done
better, its a human error, not a code error
[2009/03/12 15:15] Marcus Llewellyn: Tuesday 2000 UTC, Thurs 2100 UTC
[2009/03/12 15:15] Snowdrop Short: we have beginners classes every
thursday from 21 gmt
[2009/03/12 15:16] Snowdrop Short: and tuesdays is for programmers
wanting to learn c# syntax
[2009/03/12 15:16] Snowdrop Short: and Object Oriented programming
[2009/03/12 15:16] Marcus Llewellyn: I missed last Tues... RL was a
bastard that day. :(
[2009/03/12 15:16] Adelle Fitzgerald: lol
[2009/03/12 15:16] kidd piko: lol
[2009/03/12 15:16] Tiffany Sicling: cool re when :)
[2009/03/12 15:16] Starky Rubble: here
[2009/03/12 15:16] Tiffany Sicling: don't TP to RL
[2009/03/12 15:16] Tiffany Sicling P
[2009/03/12 15:16] Marcus Llewellyn: lol
[2009/03/12 15:16] Adelle Fitzgerald: rl is scary
[2009/03/12 15:16] Snowdrop Short: ok .. I'm off
[2009/03/12 15:16] Adelle Fitzgerald: but has awesome graphics
[2009/03/12 15:16] Marcus Llewellyn: Thanks, Snowdrop. :)
[2009/03/12 15:16] Starky Rubble: bye
[2009/03/12 15:17] Snowdrop Short: as usual if you have anything, you
can catch me on IRC
[2009/03/12 15:17] Adelle Fitzgerald: okies Snowdrop, sleep well and
thanks
[2009/03/12 15:17] Tiffany Sicling: yes, the video is fantastic in RL
[2009/03/12 15:17] Adelle Fitzgerald: :)
[2009/03/12 15:17] Marcus Llewellyn: lol
[2009/03/12 15:17] kidd piko: thank you, Snowdrop. Bye!
[2009/03/12 15:17] Snowdrop Short: thank you for listening to me
[2009/03/12 15:17] Snowdrop Short: nite
[2009/03/12 15:17] Tiffany Sicling: thanx snowdrop! :)
http://www.pastebin.ca/1359316
using System;
namespace Calculator
{
class MainClass
{
public static void Main(string[] args)
{
string str1;
string str2;
int num1;
int num2;
string func;
int result;
bool exitFlag = false;
do
{
Console.Write("Please enter a number or Q to quit: ");
str1 = Console.ReadLine();
while (!int.TryParse(str1, out num1) & ((str1 != "Q")
& (str1 != "q")))
{
Console.WriteLine("Please try again. " + str1 + "
is not a NUMBER or Q");
str1 = Console.ReadLine();
}
if ((str1 != "Q") & (str1 != "q"))
{
Console.Write("Please enter a number or Q to quit:
");
str2 = Console.ReadLine();
while (!int.TryParse(str2, out num2) & ((str2 !=
"Q") & (str2 != "q")))
{
Console.WriteLine("Please try again. " + str2
+ " is not a NUMBER or Q");
str2 = Console.ReadLine();
}
if ((str2 != "Q") & (str2 != "q"))
{
Console.Write("Please enter a + to ADD, a - to
SUBTRACT, or Q to quit: ");
func = Console.ReadLine();
while ((func != "+") & (func != "-") & (func !
= "q") & (func != "q"))
{
Console.WriteLine("Please try again. " +
func + " is not a '+', a '-', or Q");
return;
}
switch (func)
{
case "-":
result = num1 - num2;
break;
case "+":
result = num1 + num2;
break;
default:
result = 0;
exitFlag = true;
goto denoument;
}
Console.WriteLine(num1.ToString() + " " + func
+ " " + num2.ToString() + " = " + result.ToString());
}
else
{
exitFlag = true;
}
}
else
{
exitFlag = true;
}
} while (exitFlag != true);
denoument:
Console.WriteLine("Thanks and bye!");
Console.ReadLine();
}
}
}
http://pastebin.ca/1359318
using System;
namespace ConsoleCalculator
{
class Calculator
{
static void Main(string[] args)
{
int num1, num2, result;
string op;
Console.Write("Enter the first digit: ");
if (!int.TryParse(Console.ReadLine(), out num1))
{
Console.WriteLine("You must enter a valid integer.");
WaitForIt();
return;
}
Console.Write("Enter the second digit: ");
if (!int.TryParse(Console.ReadLine(), out num2))
{
Console.WriteLine("You must enter a valid integer.");
WaitForIt();
return;
}
Console.Write("Enter an operator (+ or -): ");
op = Console.ReadLine();
if (!Perform(op, num1, num2, out result))
{
Console.WriteLine("You must enter a plus or minus.");
WaitForIt();
return;
}
else
{
Console.WriteLine("The result is: " + result);
WaitForIt();
}
}
private static void WaitForIt()
{
Console.Write("Press Enter Key to continue...");
Console.ReadLine();
}
private static bool Perform(string op, int num1, int num2, out
int result)
{
switch (op)
{
case "+":
result = num1 + num2;
return true;
case "-":
result = num1 - num2;
return true;
default:
result = 0;
return false;
}
}
}
}
http://www.pastebin.ca/1359319
using System;
namespace Calculator
{
class MainClass
{
public static void Main(string[] args)
{
//Read the first integer from the console
string lineA = Console.ReadLine();
int a;
if (!int.TryParse(lineA, out a))
{
Console.WriteLine("The number must be an integer");
return;
}
//Read operator from the console as a string
string lineB = Console.ReadLine();
//Read the second number from the console
string lineC = Console.ReadLine();
int b;
if (!int.TryParse(lineC, out b))
{
Console.WriteLine("The number must be an integer");
return;
}
//Perform the calculation and output to the console
switch (lineB)
{
case "+":
Console.WriteLine("Sum of {0} and {1} = {2}", a,
b, a + b);
return;
case "-":
Console.WriteLine("Difference of {0} and {1} =
{2}", a, b, a - b);
return;
default:
Console.WriteLine("{0} is not the correct
operand", lineB);
return;
}
}
}
}