Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 19 20 [21] 22 23 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 888153 times)

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #300 on: January 09, 2012, 07:41:02 pm »

supposed to drink the whole bottle in one tic?

There is... Another way?

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #301 on: January 09, 2012, 07:43:17 pm »

supposed to drink the whole bottle in one tic?

There is... Another way?

Yeah...it's the weirdest thing...if you spread out drinking to three or four tics, you can taste it!!  Some people don't like this approach, but to them I say, "Why are you spending money on real drinks when you can buy Everclear if all you want is alcohol?"
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #302 on: January 09, 2012, 07:44:34 pm »

I think you missed the part where I conjure drinks out of thin air...

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #303 on: January 09, 2012, 07:49:28 pm »

I think you missed the part where I conjure drinks out of thin air...

You never said that didn't cost money.  At the very least, it costs a few CPU cycles.  And if not...you mind sending a few of those my way?
Logged

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #305 on: January 09, 2012, 07:56:53 pm »

It's a private attribute man.  :P

That's what getters and setters are for. :P
Code: [Select]
stargrasper.setBottle(max_white.getBottle(new Bottle(Drinks.CIDER));
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #306 on: January 09, 2012, 07:59:48 pm »

Na man, I'm c#, we can do this really cool thing where we hide a method as an attribute, it's awesome. Watch.
Code: [Select]
public Bottle Drink
{
get
{
return this.activeDrink;
}
}

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #307 on: January 09, 2012, 08:08:44 pm »

Na man, I'm c#, we can do this really cool thing where we hide a method as an attribute, it's awesome. Watch.
Code: [Select]
public Bottle Drink
{
get
{
return this.activeDrink;
}
}

Hide a method as an attribute...  I'm pretty sure I see a method as the outermost thing...and it contains another method, get...and it's public.

Either way, public Bottle Drink is a public method that returns a Bottle of the active drink!  If it's public, what's stopping me from using it for conjuration??

EDIT:
Looking back to my tutorial roadmap, how would people advise handling going back to concepts I intentionally skipped for one reason or other, forgot, or otherwise missed?  Should that be it's own little lessonlet?  Should I append it to a lesson that I'm already expecting to be kind of long (Arrays and Loop)?  Try to save it to append to a shorter lesson (which may be awhile)?
« Last Edit: January 09, 2012, 08:27:28 pm by Stargrasper »
Logged

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #308 on: January 09, 2012, 08:28:11 pm »

Na man, I'm c#, we can do this really cool thing where we hide a method as an attribute, it's awesome. Watch.
Code: [Select]
public Bottle Drink
{
get
{
return this.activeDrink;
}
}
Either way, public Bottle Drink is a public method that returns a Bottle of the active drink!  If it's public, what's stopping me from using it for conjuration??

Hmmm...

Code: [Select]
this.Drink(new Bottle(Drinks.CIDER));

There are some gaping discrepancies between the Drink methods in these examples.
Logged

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #309 on: January 09, 2012, 08:32:54 pm »

Not so much.  It's just an overloaded method.  The one without parameters returns the active drink while the one with parameters returns the input drink.  Although I suppose I should be worried about the fact that when you Drink something, it returns what you're drinking...  Does that mean you're puking it back or is it coming out the other end?
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #310 on: January 09, 2012, 08:34:24 pm »

...
Fuck internally consistent logic.

Hide a method as an attribute...  I'm pretty sure I see a method as the outermost thing...and it contains another method, get...and it's public.

Point is that you would invoke it with
Code: [Select]
Bottle stolenBottle = max.Drink;No arguments, not even parentheses. From the point of view of any other class, it looks just like an attribute.

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #311 on: January 09, 2012, 08:39:15 pm »

...
Fuck internally consistent logic.

Hide a method as an attribute...  I'm pretty sure I see a method as the outermost thing...and it contains another method, get...and it's public.

Point is that you would invoke it with
Code: [Select]
Bottle stolenBottle = max.Drink;No arguments, not even parentheses. From the point of view of any other class, it looks just like an attribute.

So you can overload attributes with methods? Sounds cool, but I prefer not having non-private attributes at all.
Logged

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #312 on: January 09, 2012, 08:40:53 pm »

...
Fuck internally consistent logic.

Hide a method as an attribute...  I'm pretty sure I see a method as the outermost thing...and it contains another method, get...and it's public.

Point is that you would invoke it with
Code: [Select]
Bottle stolenBottle = max.Drink;No arguments, not even parentheses. From the point of view of any other class, it looks just like an attribute.

Neat.

I need to find a day to play with C#.  I really do.  Do either of you, or anyone else, have advice handling my tutorial roadmap?  I'm going to have to backpedal at some point.
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #313 on: January 09, 2012, 08:47:02 pm »

So you can overload attributes with methods? Sounds cool, but I prefer not having non-private attributes at all.
That is the point, it acts like a method. You can throw what ever you like inside a get or set, including thread safeing. Your innocent private attributes remain safe from being set at the will or any other class, letting methods pretending to be attributes take the grunt work.
It replaces the need to always use methods for getters and setters.

I need to find a day to play with C#.  I really do.

Think that is cool? Nameless methods, commonly called indexes. They are not just for arrays.

This
Code: [Select]
public Bottle this[int index]
{
get
{
return this.fridge[index];
}
}
is invoked by this
Code: [Select]
int x = GetSomeInt();
Bottle stolenBottle = max[x];

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #314 on: January 09, 2012, 08:49:08 pm »

This
Code: [Select]
public Bottle this[int index]
{
get
{
return this.fridge[index];
}
}
is invoked by this
Code: [Select]
int x = GetSomeInt();
Bottle stolenBottle = max[x];

Where exactly?
Logged
Pages: 1 ... 19 20 [21] 22 23 ... 796