Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Programming
You last visited: Today at 10:49

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Programming for Idiots (C#) - Take 2

Discussion on Programming for Idiots (C#) - Take 2 within the CO2 Programming forum part of the Conquer Online 2 category.

Closed Thread
 
Old 12/17/2010, 20:01   #31
 
elite*gold: 0
Join Date: Sep 2008
Posts: 694
Received Thanks: 207
Quote:
Originally Posted by tanelipe View Post
People don't read stickys (judging by the amount of rule-breakers this forum has) so it's better to just leave it amongst normal threads.
No, people don't read rules cause they are boring, useless and most likely a freakin wall of text. And the egies don't even understand what it says anyways.
DragonHeart is offline  
Thanks
1 User
Old 12/18/2010, 03:53   #32
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
@ Above: I agree with you. In all honesty, nobody reads the rules until they start getting bans or warnings.

Well it's no problem if this isn't stickied. My other one containing videos is stickied, and I added a link noting that it was superseded by this one.

Anyhow, I'll try to get up a lesson on structures (I'm going to break this down into two parts). If anyone cares why I'm breaking it down into two parts, in one, I'm going to talk about using structures the way I do, and in the other, I'm going to talk about general-case scenarios as to how they can be used (but I wouldn't use them as such).
InfamousNoone is offline  
Thanks
1 User
Old 12/18/2010, 09:01   #33
 
elite*gold: 0
Join Date: Dec 2010
Posts: 9
Received Thanks: 3
ty bud, e*pvp should thank you 4ever for your great releases and your willing to help this forum. ty again! im learning your guide right now and you know what? you explained this shit very well so everyone can learn it thanks again. i would rape the thanks button if i could thank you more than one time

Later edit: I think is a problem at lesson five - bool values

Code:
            if (condition)
            {
                // code to execute if condition is true
            }
            else if (condition2)
            {
                // code to execute if condition is false
                // and condition2 is true
            }
            else
            {
                // code to execute if condition is false
                // and condition2 is false
            }
i think you need to add the "if" for the 3rd condition also (where the code execute if the both conditions are false). ifi let it like it is right now without the "if" at the 3rd statement, error pop up but if i add "if" everything works fine. here's the code


Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Tell me how much money you have in your pockets");
            double amount = double.Parse(Console.ReadLine());
            if (amount > 2000.00)
            {
                Console.WriteLine("You are rich");
                Console.ReadLine();
            }
            else if (amount == 2000.00)
            {
                Console.WriteLine("You are fine");
                Console.ReadLine();
            }
            else if (amount < 2000.00)
            {
                Console.WriteLine("You are poor");
                Console.ReadLine();
            }
            
        }

    }
}
tell me if i am wrong!!!
co_george is offline  
Old 12/18/2010, 11:15   #34


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
I was going to sticky this once Unit 2/3 had been completed so that there was alot of content available.
Korvacs is offline  
Thanks
1 User
Old 12/18/2010, 11:42   #35
 
_Emme_'s Avatar
 
elite*gold: 1142
Join Date: Aug 2006
Posts: 2,464
Received Thanks: 1,162
Quote:
Originally Posted by co_george View Post


[code]using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Tell me how much money you have in your pockets");
double amount = double.Parse(Console.ReadLine());
if (amount > 2000.00)
{
Console.WriteLine("You are rich");
Console.ReadLine();
}
else if (amount == 2000.00)
{
Console.WriteLine("You are fine");
Console.ReadLine();
}
else if (amount < 2000.00)
{
Console.WriteLine("You are poor");
Console.ReadLine();
}

}

}
}
You can use ternary operations for calls like that. Here's an example:

Code:
static void Main(string[] args)
        {
            Console.WriteLine("Please insert how much money you have in your pockets");
            Console.Write("Amount: ");
            double amount = double.Parse(Console.ReadLine());
            Console.WriteLine(amount > 2000 ? "You are rich!" : "You are poor!");
        }
Ternary operation - Wikipedia, the free encyclopedia
_Emme_ is offline  
Old 12/18/2010, 11:56   #36
 
elite*gold: 0
Join Date: Dec 2010
Posts: 9
Received Thanks: 3
Thats really awesome Emme but i just started with C# and i dont know very much about, just following Hybrid's guides and trying to understand them (now i'm stuck at Lesson 6 - While Loops). I still have a question. My ****** code it's actually working fine and there's not problem writing the code like mine or like you isnt it? I know your code it's smaller just 4 codelines but doesnt really matter if i do in my way. What i mean it's correct what i done or not ?
co_george is offline  
Old 12/18/2010, 12:40   #37
 
_Emme_'s Avatar
 
elite*gold: 1142
Join Date: Aug 2006
Posts: 2,464
Received Thanks: 1,162
Quote:
Originally Posted by co_george View Post
Thats really awesome Emme but i just started with C# and i dont know very much about, just following Hybrid's guides and trying to understand them (now i'm stuck at Lesson 6 - While Loops). I still have a question. My shitty code it's actually working fine and there's not problem writing the code like mine or like you isnt it? I know your code it's smaller just 4 codelines but doesnt really matter if i do in my way. What i mean it's correct what i done or not ?
I see.

The way you're doing it is like

Code:
if (amount > 2000.00)
{
Console.WriteLine("You are rich");
Console.ReadLine();
}
else if (amount == 2000.00)
{
Console.WriteLine("You are fine");
Console.ReadLine();
}
else if (amount < 2000.00)
{
Console.WriteLine("You are poor");
Console.ReadLine();
}

but if you want it done that way, you should do:

Code:
static void Main(string[] args)
{
Console.WriteLine("Enter the amount of money in your pockets");
Console.Write("Amount: ");
double amount = double.Parse(Console.ReadLine());

if(amount > 2000) // Checks if amount is 2001 or above
 Console.WriteLine("You are rich");
else if(amount < 2000) // Checks if amount is 1999 or under
 Console.WriteLine("You are poor");
else //Else if amount isn't under 1999 or over 2001, it is 2000.
 Console.WriteLine("You are fine");

Console.ReadLine();

}
_Emme_ is offline  
Thanks
1 User
Old 12/18/2010, 12:45   #38
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
Quote:
Originally Posted by co_george View Post
ty bud, e*pvp should thank you 4ever for your great releases and your willing to help this forum. ty again! im learning your guide right now and you know what? you explained this shit very well so everyone can learn it thanks again. i would rape the thanks button if i could thank you more than one time

Later edit: I think is a problem at lesson five - bool values

Code:
            if (condition)
            {
                // code to execute if condition is true
            }
            else if (condition2)
            {
                // code to execute if condition is false
                // and condition2 is true
            }
            else
            {
                // code to execute if condition is false
                // and condition2 is false
            }
i think you need to add the "if" for the 3rd condition also (where the code execute if the both conditions are false). ifi let it like it is right now without the "if" at the 3rd statement, error pop up but if i add "if" everything works fine. here's the code


Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Tell me how much money you have in your pockets");
            double amount = double.Parse(Console.ReadLine());
            if (amount > 2000.00)
            {
                Console.WriteLine("You are rich");
                Console.ReadLine();
            }
            else if (amount == 2000.00)
            {
                Console.WriteLine("You are fine");
                Console.ReadLine();
            }
            else if (amount < 2000.00)
            {
                Console.WriteLine("You are poor");
                Console.ReadLine();
            }
            
        }

    }
}
tell me if i am wrong!!!
What you did was absolutely correct. Let's take a look at what you said. You wanted to know why this was wrong:
Code:
            Console.WriteLine("Tell me how much money you have in your pockets");
            double amount = double.Parse(Console.ReadLine());
            if (amount > 2000.00)
            {
                Console.WriteLine("You are rich");
                Console.ReadLine();
            }
            else if (amount == 2000.00)
            {
                Console.WriteLine("You are fine");
                Console.ReadLine();
            }
            else (amount < 2000.00)
            {
                Console.WriteLine("You are poor");
                Console.ReadLine();
            }
The reason it is wrong is because, is because the "else" case should only be used when all above conditions are false. What you were trying to do, was specify another condition to check: (amount < 2000.00), so for this we would use else if as you had done .

Something to think about though is
Code:
            Console.WriteLine("Tell me how much money you have in your pockets");
            double amount = double.Parse(Console.ReadLine());
            if (amount > 2000.00)
            {
                Console.WriteLine("You are rich");
                Console.ReadLine();
            }
            else if (amount == 2000.00)
            {
                Console.WriteLine("You are fine");
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("You are poor");
                Console.ReadLine();
            }
Would work perfectly fine! Because, above your final else statement, we check if amount > 2000.00 and amount == 2000.00, and if both of these are false -- then amount < 2000.00 must be true!

Quote:
Originally Posted by Korvacs View Post
I was going to sticky this once Unit 2/3 had been completed so that there was alot of content available.
Thanks a lot Jack for the support. Really appreciated.

Quote:
Originally Posted by EmmeTheCoder View Post
You can use ternary operations for calls like that. Here's an example:

Code:
static void Main(string[] args)
        {
            Console.WriteLine("Please insert how much money you have in your pockets");
            Console.Write("Amount: ");
            double amount = double.Parse(Console.ReadLine());
            Console.WriteLine(amount > 2000 ? "You are rich!" : "You are poor!");
        }
Ternary operation - Wikipedia, the free encyclopedia
While using the ternary operator is simpler, it is not easier for early programmers to understand. The early-on unit-one series' goal isn't to create good programming habits, but to familiarize new programmers with the language.

Quote:
Originally Posted by co_george View Post
Thats really awesome Emme but i just started with C# and i dont know very much about, just following Hybrid's guides and trying to understand them (now i'm stuck at Lesson 6 - While Loops). I still have a question. My shitty code it's actually working fine and there's not problem writing the code like mine or like you isnt it? I know your code it's smaller just 4 codelines but doesnt really matter if i do in my way. What i mean it's correct what i done or not ?
You're absolutely right. At this point in time, it doesn't matter how you do it as long as you understand what you are doing!.

Directed more at Emme, not George:
However, it should be noted, your code and Emme's code carries a significant difference. Your code checks for 3 things equality, greater than, & lesser than, using the ternary operator as Emme has done is checking for greater than and if not, lesser than or equal to. So NO. One ternary operation in this case is not applicable and wrong. You can tell this is wrong because Emme's code will show two outputs on the console (poor, or rich), while yours shows three (poor, rich and fine).

Edit:
Added (Unit Two) Lesson Three - Enumerations.
Also, and edit to my last remarks in this post.
InfamousNoone is offline  
Thanks
2 Users
Old 12/18/2010, 13:23   #39
 
_Emme_'s Avatar
 
elite*gold: 1142
Join Date: Aug 2006
Posts: 2,464
Received Thanks: 1,162
Here's a pretty good list you could use to exam stages on the road of learning programming. Don't use it to see yourself as a bad programmer as you might not qualify on all the points, but use it now and then to see that you're progressing.

_Emme_ is offline  
Thanks
3 Users
Old 12/18/2010, 13:26   #40
 
elite*gold: 0
Join Date: Dec 2010
Posts: 9
Received Thanks: 3
Thank you mate for making me understand! I'm surprised how much willing to help you are.
Same goes for you Emme
co_george is offline  
Old 12/18/2010, 13:32   #41
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
Quote:
Originally Posted by EmmeTheCoder View Post
Here's a pretty good list you could use to exam stages on the road of learning programming. Don't use it to see yourself as a bad programmer as you might not qualify on all the points, but use it now and then to see that you're progressing.

Skimming over that link, it seems more targeted at C/C++ programmers rather than higher-level language programmers (i.e. Java, C#, et cetra).

Edit:
No problem, all in a days work.
InfamousNoone is offline  
Old 12/18/2010, 19:02   #42
 
hok30's Avatar
 
elite*gold: 0
Join Date: Feb 2007
Posts: 1,366
Received Thanks: 256
Quote:
Originally Posted by InfamousNoone View Post
Skimming over that link, it seems more targeted at C/C++ programmers rather than higher-level language programmers (i.e. Java, C#, et cetra).

Edit:
No problem, all in a days work.
Holy ****. How are you still here? I used this tutorial like a year ago. (video)
hok30 is offline  
Old 12/18/2010, 23:58   #43
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
Quote:
Originally Posted by hok30 View Post
Holy ****. How are you still here? I used this tutorial like a year ago. (video)
Due to be quitting retail CO, a lot of spare time has opended up for me (and not to mention, now I'm on winter breaK). So, I've got a lot of time, with a whole lot of nothing tot do. So, I ifgure, might as well do something productive, eh?

Edit:
Added Lesson Four - Bit Operations and Enumerations (II).
InfamousNoone is offline  
Thanks
1 User
Old 12/19/2010, 03:52   #44
 
xScott's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 322
Received Thanks: 63
wonder if you could, or if your intending to anyway, talk about stackalloc, and using out & ref. <--- tis completely confused me, learning vb as my first language :S

these bitwise operations finally put my knowledge of truth tables and logic gates to some use, haha.
xScott is offline  
Old 12/19/2010, 04:02   #45
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
Quote:
Originally Posted by xScott View Post
wonder if you could, or if your intending to anyway, talk about stackalloc, and using out & ref. <--- tis completely confused me, learning vb as my first language :S
No problem. I can cover ref/out in the next lesson -- but, I'm not going to cover stackalloc until "Welcome to the darkside".

Edit:
Lesson Five - Out, Ref and Nullable Types
InfamousNoone is offline  
Thanks
1 User
Closed Thread


Similar Threads Similar Threads
Programming For Idiots (Tutorial) - In C#
05/25/2013 - CO2 Programming - 188 Replies
This tutorial has been superseded by: http://www.elitepvpers.com/forum/co2-programming/88 5939-programming-idiots-c-take-2-a.html Well for the next week (or so) due to being bored, I've started a video-tutorial called C# Programming for Idiots and yeah, by the end of it I'll demonstrate how to make a conquer server (patch 5016 and before) without the need of mysql, or anything like that; all you need is the Visual C# compiler, and WinRAR (To extract the videos). Visual C# Compiler:...
Programming for Idiots (Tutorial) C++
06/11/2012 - CO2 Programming - 20 Replies
Yeah, so in my relation to my C# one (http://www.elitepvpers.com/forum/co2-guides-templa tes/148675-programming-idiots-tutorial-c.html), which wasn't the best I felt I'll *try* make for it with this one. I've also got some spare time in between school, from when exams start, and a new Warlords server comes out... so yeah. Right, so before I post any links to the videos I'd like to point out, so I don't get bitched at by people saying, "this isn't real C++", most of the things I do will be...
[RE-OPENING]"Programming For Idiots (Tutorial) - In C#"
09/17/2009 - CO2 Programming - 20 Replies
At start i want to say THIS IS NOT MY GUIDE , GUIDE WAS MADE BY INFAMOUSNONE!!



All times are GMT +1. The time now is 10:49.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.