Silabsoft Forums: Concept Of An If-Then And An If-Then-Else Statement - Silabsoft Forums

Jump to content

Reply Rules

[*]"Leeching" - This is a moparscape term. Here at silabsoft we do not believe in the term. I only care if you blatantly plagiarize work from a creditable source.
[*] Flaming - It's not allowed anywhere on these boards.
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic
  • Bookmark

Concept Of An If-Then And An If-Then-Else Statement

#1 User is offline   i r maggot Icon

  • Advanced Member
  • PipPipPip
  • Group: Retired Staff
  • Posts: 3,761
  • Joined: 30-December 08
  • Gender:Male

Posted 07 November 2009 - 12:39 AM

All if statements are really just biconditionasl. (if you don't know what that is, then you must have failed geometry)

ie:
If you live in the USA, then you live in North America.
if(country.equalsIgnoreCase("USA")) {
	continent = "North America";
}


I'll break this down.

Quote

If you live in the USA,

This is equivelent to:
if(country.equalsIgnoreCase("USA")) {


That part is where all the requirements are set for the following to happen. Believe it or not, Java speaks English.
if(requirement) {
	//what happens if requirement is met
}



This is where the real action happens. This is what happens if the requirements are met.


Quote

then you live in North America.

This is equivelent to:
continent = "North America";

This will only be done if the country is USA.

Let's try this.
You live in Brazil.
country = "Brazil";

if(country.equalsIgnoreCase("USA") {

Oh, but wait, your in Brazil. This won't work. The following will not be done.


if-then-else statements are about the same. They are basically two if-then statements combined.

There are two ways to use them.
if(req = true){
	then();
} else {
 ifReqWasntMet();
}

or
if(req = true){
	then();
} else if(req = false) {
 ifReqWasntMet();
}

If you read the beginning, you should understand this.
Understand? If not, then google biconditionals.

Anyway, this would be applied in nearly EVERYTHING that has requirements unless you use a switch.
Posted Image
0

#2 User is offline   Ownage-Pkerzs Icon

  • Advanced Member
  • PipPipPip
  • Group: Senior Member
  • Posts: 65
  • Joined: 25-August 09
  • Gender:Male

Posted 07 November 2009 - 01:54 AM

Pretty good. This should help all the new people learn something new.
Join the most creative and fun server out there!

Ownage-Pkerz.tk, Ownage-Pkerzs.no-ip.biz
Don't miss out becoming an Ownage-Pker!
0

#3 User is offline   melee wins Icon

  • Advanced Member
  • PipPipPip
  • Group: Senior Member
  • Posts: 151
  • Joined: 22-August 09

Posted 07 November 2009 - 08:52 AM

you always have to f****** be better then me!
Posted Image

Malice hero! The one who kept me going.
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic
  • Bookmark