Simple c# exercise for beginners. I'm stuck -


i'm doing exercise in c# practice i'm not sure , how i'm supposed things. (i'm not thinking compiler yet) :( .

the exercise set this.

  • we have 2 children, , b, , parameters asmile , bsmile indicate if each smiling.
  • we in trouble if both smiling or if neither of them smiling.
  • return true if in trouble.
  • areweintrouble(true, true) -> true
  • areweintrouble(false, false) -> true
  • areweintrouble(true, false) -> false

public bool areweintrouble(bool asmile, bool bsmile) {}

my code until now:

public bool areweintrouble(bool asmile, bool bsmile)     {          if (asmile == true && bsmile == true)         {             return true;         }         else if (asmile == false && bsmile == false)         {             return true;         }         else             return false;      } 

i have put put method in main method in program.cs once program starts method gets called.

static void main(string[] args)     {         areweintrouble(asmile, bsmile);     } 

but when call method error , b smile not exist in current content.

so id ask if can give me hints/tips solving exercise. i'm not sure how proceed here id understand missing , retry it.

thank guys help!

you should pass in values, since asmile , bsmile aren't know variables in method.

from example:

 areweintrouble(true, false); 

second, should catch return value:

 bool result = areweintrouble(true, false); 

and possibly display it:

 bool result = areweintrouble(true, false);  console.writeline("are in trouble? {0}", result); 

also, make method static since main method is:

public static bool areweintrouble(bool asmile, bool bsmile) { } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -