Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 602 603 [604] 605 606 ... 796

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

Gentlefish

  • Bay Watcher
  • [PREFSTRING: balloon-like qualities]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9045 on: February 16, 2016, 01:13:01 am »

That's exactly it.

Your prof said you're not allowed to modify the class. But you're allowed to modify objects using class functions.

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #9046 on: February 16, 2016, 01:13:23 am »

...no? not at all, python's where i learned the distinction

an object is an instantiation of a class
Whaaaaaaaaaaaat

That's a completely different way of thinking about it than I'm used to
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #9047 on: February 16, 2016, 01:54:09 am »

I'm... increasingly unsure.

An instance of something is the same as the thing of which it's an instance, apparently
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

3man75

  • Bay Watcher
  • I will fire this rocket
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9048 on: February 16, 2016, 02:00:27 am »

Spoiler (click to show/hide)

Sorry but last question: How do I add the object to the arraylist?[/code]
Logged

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9049 on: February 16, 2016, 03:04:46 am »

I'm... increasingly unsure.

An instance of something is the same as the thing of which it's an instance, apparently

It's useful to think of it in terms of real-world objects.

Dogs (the class) are something with fur, four legs, two eyes and a tail.

Some dogs (instances) are chihuahuas, dalmations, black labs, etc.

Fun fact: I wrote like ten different comparisons before hitting on one that wasn't confusing and unhelpful.
« Last Edit: February 16, 2016, 03:08:32 am by itisnotlogical »
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9050 on: February 16, 2016, 03:22:29 am »

apples

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9051 on: February 16, 2016, 03:27:09 am »

I started with mailboxes because that's the traditional metaphor for variables. It wasn't as helpful for explaining classes. :P
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9052 on: February 16, 2016, 03:41:48 am »

and inheritance is like how apple is subclass of fruit and composition where core is part of apple but not grape.

and apple can be like Apple('green','sorta sour','crispy') or Apple('red','bittersweet','sorta mushy') though that's awfully human-centric way of thinking about it. just remember: more can be said about an apple than every apple

also, one more thing: RED DELICIOUS IS GROSS YO

time to go to bed i think

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #9053 on: February 16, 2016, 03:42:42 am »

I'm just going to stick with functional programming
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9054 on: February 16, 2016, 03:53:23 am »

why's it always gotta be so complicated

i was about to say go with procedural, but they make that an analogy to OOP for some utterly god-forsaken reason

the sun does not shine on whoever comes up with these labels

...huh, that's probably literally true, now that i think of it

NERDS

EDIT:

Code: [Select]
APawn* const Pawn = GetPawn();
FVector velocity = Pawn->GetVelocity();
FTransform transform = Pawn->GetTransform();

that second line causes unreal engine 4 to crash when I try to convert it to a blueprint for UI design purposes

what a feeling that is, to begin work on something and immediately screw it up so bad that it crashes code made by some of the best engine writers in the industry

it works fine as C++, really quite perfect, but when I convert it to blueprint it doesn't work

to that end, screw blueprints, i'm sticking with c++
« Last Edit: February 16, 2016, 03:56:57 am by Putnam »
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9055 on: February 16, 2016, 04:52:25 am »

I'm... increasingly unsure.

An instance of something is the same as the thing of which it's an instance, apparently

It's useful to think of it in terms of real-world objects.

Dogs (the class) are something with fur, four legs, two eyes and a tail.

Some dogs (instances) are chihuahuas, dalmations, black labs, etc.

Fun fact: I wrote like ten different comparisons before hitting on one that wasn't confusing and unhelpful.

That's potentially confusing, because dog breeds may be child classes of dog. e.g. "chihuahuas are a type of dog" is saying "class chihuahua derives from class dog" in OOP-speak. Whereas "this is my dog (an object) he is a chihuahua" (a class, which is also a subclass of the "dog" class).
« Last Edit: February 16, 2016, 04:56:20 am by Reelya »
Logged

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9056 on: February 16, 2016, 05:49:39 am »

Spoiler (click to show/hide)

Sorry but last question: How do I add the object to the arraylist?[/code]
...
No.

Code: [Select]
System.out.println("Please input the name of the account holder.");

String name = namingAccount.nextLine();

//By the way, you really shouldn't name your Scanner that,
//it's not at all relevant to what it actually does.

arraylistvar.add(new BankAccount(name));

//You have this constructor, right?  Use it.  If you don't, make it.
//Also you can do this. 
//Though you'll need to keep track of where your variable goes in the array somewhere.

Here's how I think of classes/instances:A class describes the shared features of something.  A (properly-instantiated) instance of a class is something that has those features.  Those features may be instances of other classes, etc. etc..

For instance, a book has a title, an ISBN, an author, etc., and pissibly a person to whom it's loaned out.  That person has a name, and age, and some books they own or rent.
« Last Edit: February 16, 2016, 06:00:58 am by TheBiggerFish »
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #9057 on: February 16, 2016, 06:20:24 am »

I'm... increasingly unsure.

An instance of something is the same as the thing of which it's an instance, apparently

It's useful to think of it in terms of real-world objects.

Dogs (the class) are something with fur, four legs, two eyes and a tail.

Some dogs (instances) are chihuahuas, dalmations, black labs, etc.

Fun fact: I wrote like ten different comparisons before hitting on one that wasn't confusing and unhelpful.

That's potentially confusing, because dog breeds may be child classes of dog. e.g. "chihuahuas are a type of dog" is saying "class chihuahua derives from class dog" in OOP-speak. Whereas "this is my dog (an object) he is a chihuahua" (a class, which is also a subclass of the "dog" class).
I'd feel that dog breeds is a bad example of subclassing. Are different breeds really so different that you want subclasses, or is it better to store attributes in data and populate it with a factory? :v
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9058 on: February 16, 2016, 06:45:26 am »

To be honest, almost all examples of sub-classing are bad examples. The mechanism itself is very over-rated, and leads to poor code that's hard to maintain. It's just an example.

For example, the canonical "person, student, teacher" example is very obviously flawed. What do you now do if a teacher themselves enrols in a subject?

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9059 on: February 16, 2016, 06:47:22 am »

You don't need subclasses for dog breeds.
Logged
Pages: 1 ... 602 603 [604] 605 606 ... 796