11 Replies - 1251 Views - Last Post: 26 June 2009 - 05:33 AM Rate Topic: -----

#1 jordie91   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 13-June 09

if statement

Posted 24 June 2009 - 06:43 AM

below is my code i have made a comment were i want to put my if statement

i want make an if statement the shows if i have 20 pages and i want read 30 from it that i get a error with the folowwing example "you want to read {0} pages but you only have {0} pages left

i want to
 using System;
using System.Collections.Generic;
using System.Text;

namespace boeken
{
	 class boeken
	{
		string Titel;
		string Auteur;
		string ISBN;
		int bladzijden;
		int bladzijdenGelezen;


		public boeken()
		{
			this.bladzijden = 0;
			this.bladzijdenGelezen = 0;
		}

		public boeken (string Titel,string Auteur,string ISBN,int bladzijden)
		{
			this.Titel = Titel;
			this.Auteur = Auteur;
			this.ISBN = ISBN;
			this.bladzijden = bladzijden;
			this.bladzijdenGelezen = 0;
		}
		
		public void gegevensuitvoer ()
		{
			Console.WriteLine ("de titel van het boek is  :" + Titel);
			Console.WriteLine ("de auteur van het boek is :" + Auteur);
			Console.WriteLine ("het isbn nummer is : " + ISBN);  
		}


		 //public toegankelijkeid van de methode bij de aanroep op een object kappen.
		 //int is RETURN TYPE
		 //lezen is de NAAM van de METHODE
		 //(int blz) de PARAMETER die je hieronder mee moet geven
		public void lezen(int aantalbladzijdengelezen)
		{
			
			 
			 this.bladzijdenGelezen = this.bladzijdenGelezen - aantalbladzijdengelezen;
			// here i want to add an if statement
			 
		 }

		 public int gelezen()
		 {
			
			int som;
			som = this.bladzijden - this.bladzijdenGelezen;
			 if (som <= 0 )
			 {
				 Console.WriteLine("je hebt het boek uit");
			 }
			 else
			 {
				 Console.WriteLine("je moet nog {0} bladzijden lezen", som);
			 }
			 return this.bladzijdenGelezen;
			

			 



Is This A Good Question/Topic? 0
  • +

Replies To: if statement

#2 RudiVisser   User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1010
  • View blog
  • Posts: 3,566
  • Joined: 05-June 09

Re: if statement

Posted 24 June 2009 - 06:44 AM

I'm going to guess that the project you're working on is for homework, am I correct??

I really suggest that you go find some basic tutorials for C#..
Was This Post Helpful? 0
  • +
  • -

#3 SwiftStriker00   User is offline

  • No idea why my code works
  • member icon

Reputation: 439
  • View blog
  • Posts: 1,617
  • Joined: 25-December 08

Re: if statement

Posted 24 June 2009 - 06:52 AM

Whatever this project is, hes has taken the time to break it up over numerous topics. I mean not hard to notice every time German code being presented
Was This Post Helpful? 0
  • +
  • -

#4 RudiVisser   User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1010
  • View blog
  • Posts: 3,566
  • Joined: 05-June 09

Re: if statement

Posted 24 June 2009 - 06:54 AM

View PostSwiftStriker00, on 24 Jun, 2009 - 05:52 AM, said:

Whatever this project is, hes has taken the time to break it up over numerous topics. I mean not hard to notice every time German code being presented

Yes but the problem is that he doesn't seem to be learning anything, just copying the code that is given on the forums. I for one am not helping people who don't have a clue what they're trying to do, nor understand even the basic of the solution you provided.

BTW, it's Dutch :)
Was This Post Helpful? 0
  • +
  • -

#5 SwiftStriker00   User is offline

  • No idea why my code works
  • member icon

Reputation: 439
  • View blog
  • Posts: 1,617
  • Joined: 25-December 08

Re: if statement

Posted 24 June 2009 - 07:09 AM

View PostMageUK, on 24 Jun, 2009 - 07:54 AM, said:

Yes but the problem is that he doesn't seem to be learning anything, just copying the code that is given on the forums. I for one am not helping people who don't have a clue what they're trying to do, nor understand even the basic of the solution you provided.

BTW, it's Dutch :)


Oh what you don't like being a personal debugger? Seriously though, Jordie. You do need to go through a few tutorials and get the basics down. That combined with visual studio's intellisense it shouldn't be that hard to figure out what you need done.

P.S. My bad on the language thing, most of the time i just ignore words that aren't in english when fixing code; less confusing that way :P
Was This Post Helpful? 0
  • +
  • -

#6 jordie91   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 13-June 09

Re: if statement

Posted 24 June 2009 - 07:57 AM

its not for homework

otherwise i shouldn't have make this code by myself

it are basic excersices for csharp wich i got from a friend

and i only want to try to understand csharp but this excersise i cant understand

i have a lot of others wich i finished without this forum

i only ask the things i dont know

and i understand it all but not how i can say that he read .. pages and have ... left
Was This Post Helpful? 0
  • +
  • -

#7 eclipsed4utoo   User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1536
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Re: if statement

Posted 24 June 2009 - 08:07 AM

View Postjordie91, on 24 Jun, 2009 - 09:57 AM, said:

its not for homework

otherwise i shouldn't have make this code by myself

it are basic excersices for csharp wich i got from a friend

and i only want to try to understand csharp but this excersise i cant understand

i have a lot of others wich i finished without this forum

i only ask the things i dont know

and i understand it all but not how i can say that he read .. pages and have ... left


I would suggest going to a local bookstore and getting a C# book, or ordering one from an online store. Using examples from friends aren't going to teach you much.
Was This Post Helpful? 1

#8 Renagado   User is offline

  • D.I.C Regular
  • member icon

Reputation: 118
  • View blog
  • Posts: 388
  • Joined: 14-June 09

Re: if statement

Posted 24 June 2009 - 08:21 AM

Yeah jordie a book helps, I have this one (in Dutch): Handboek Visual C# 2008 by Dirk Louis. I like it, it teaches all the basics from console applications to windows forms and has some info on ADO.net and SQL. You can get it at Selexyz for about 30 euro. Just a hint ;)
Was This Post Helpful? 0
  • +
  • -

#9 jordie91   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 13-June 09

Re: if statement

Posted 24 June 2009 - 11:54 AM

thats exactly the book i have

but i understand chapter 1 till 6 now but the only thing i dont understand is the if and else and because of that i couldnt make my method good so that you can see what you have read and how much pages you want to read too much for example
Was This Post Helpful? 0
  • +
  • -

#10 Renagado   User is offline

  • D.I.C Regular
  • member icon

Reputation: 118
  • View blog
  • Posts: 388
  • Joined: 14-June 09

Re: if statement

Posted 24 June 2009 - 03:19 PM

Well in that case, the explanation of if is on page 137, also look at the boolean expressions they are a few pages further. Plus all the syntax you need is listed in appendix D in the back of the book.

Maybe an idea, but what I always did when I started to learn programming(qbasic in my case) and I didn't understand some expression, I just wrote a very small test program. So just make a few int variables and play with the if, else if, and else. That way it's much easier to learn then if you write a full program. So make sure you understand everything in the book well, and then move on to the next chapter. Succes!(good luck;))
Was This Post Helpful? 0
  • +
  • -

#11 TomVdV   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 28-May 09

Re: if statement

Posted 26 June 2009 - 01:23 AM

Why did you still write console applications if you already use classes?

I recommend you to write winform applications. It isnít more difficult that console applications.
Was This Post Helpful? 0
  • +
  • -

#12 eclipsed4utoo   User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1536
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Re: if statement

Posted 26 June 2009 - 05:33 AM

View PostTomVdV, on 26 Jun, 2009 - 03:23 AM, said:

Why did you still write console applications if you already use classes?

I recommend you to write winform applications. It isnít more difficult that console applications.


IMO, console applications are easier to write than winform applications because you don't have to deal with controls. Also, to me, it's more of a "raw" type of programming where nothing is done for you, so it helps you learn more.

And just because he has classes doesn't mean he shouldn't be doing console applications.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1