SlideShare ist ein Scribd-Unternehmen logo
1 von 3
Super Powerful Boolean Expressions LIS4930 © PIC ‘And’ and ‘Or’ Operators (&&, ||) If the price range is between $300 and $400 then choose X: if ( price >= 300 && price < 400) { 	camera = “X”; } What if the returned results were too large, and you can only looking or brands “A” or “B”. if ( brand.equals(“A”) || brand.equals(“B”) ) { //do stuff for only brand A or brand B }
Super Powerful Boolean Expressions LIS4930 © PIC Not equals ( != and ! ) Let’s say that you have a logic like, “of the ten available comdels, a certain thing is true for all but one”. if ( model != 2000 ) { //do non-model 2000 stuff } or for comparing objects like strings… if ( !brand.equals(“X”) ) { //do non-brand X stuff }
Super Powerful Boolean Expressions LIS4930 © PIC Boolean expressions can get really big and complicated: if ((zoomType.equals(“optical”) && (zoomDegree >= 3 && zoomDegree <= 8))     ||  	(zoomType.equals(“digital”) && (zoomDegree >= 5 && zoomDegree <= 12)))  { //do appropriate zoom stuff }

Weitere ähnliche Inhalte

Mehr von Program in Interdisciplinary Computing (20)

Phpmysqlcoding
PhpmysqlcodingPhpmysqlcoding
Phpmysqlcoding
 
Database basics
Database basicsDatabase basics
Database basics
 
CGS2835 HTML5
CGS2835 HTML5CGS2835 HTML5
CGS2835 HTML5
 
Mysocial databasequeries
Mysocial databasequeriesMysocial databasequeries
Mysocial databasequeries
 
Mysocial databasequeries
Mysocial databasequeriesMysocial databasequeries
Mysocial databasequeries
 
CGS2835 HTML5
CGS2835 HTML5CGS2835 HTML5
CGS2835 HTML5
 
01 intro tousingjava
01 intro tousingjava01 intro tousingjava
01 intro tousingjava
 
Web architecture v3
Web architecture v3Web architecture v3
Web architecture v3
 
Xhtml
XhtmlXhtml
Xhtml
 
Webdev
WebdevWebdev
Webdev
 
Web architecture
Web architectureWeb architecture
Web architecture
 
Sdlc
SdlcSdlc
Sdlc
 
Mysocial
MysocialMysocial
Mysocial
 
Javascript
JavascriptJavascript
Javascript
 
Javascript
JavascriptJavascript
Javascript
 
Html5
Html5Html5
Html5
 
Frameworks
FrameworksFrameworks
Frameworks
 
Drupal
DrupalDrupal
Drupal
 
Database
DatabaseDatabase
Database
 
Javascript2
Javascript2Javascript2
Javascript2
 

08 boolean expressions

  • 1. Super Powerful Boolean Expressions LIS4930 © PIC ‘And’ and ‘Or’ Operators (&&, ||) If the price range is between $300 and $400 then choose X: if ( price >= 300 && price < 400) { camera = “X”; } What if the returned results were too large, and you can only looking or brands “A” or “B”. if ( brand.equals(“A”) || brand.equals(“B”) ) { //do stuff for only brand A or brand B }
  • 2. Super Powerful Boolean Expressions LIS4930 © PIC Not equals ( != and ! ) Let’s say that you have a logic like, “of the ten available comdels, a certain thing is true for all but one”. if ( model != 2000 ) { //do non-model 2000 stuff } or for comparing objects like strings… if ( !brand.equals(“X”) ) { //do non-brand X stuff }
  • 3. Super Powerful Boolean Expressions LIS4930 © PIC Boolean expressions can get really big and complicated: if ((zoomType.equals(“optical”) && (zoomDegree >= 3 && zoomDegree <= 8)) || (zoomType.equals(“digital”) && (zoomDegree >= 5 && zoomDegree <= 12))) { //do appropriate zoom stuff }