Započni novu temu Odgovori na temu  [ 9 Posta ] 
Autoru Poruka
PostPoslato: 29.09.2006. 22:13:13 
Moderator
Korisnikov avatar

Pridružio se: 13.11.2001. 08:45:08
Postovi: 4717
Lokacija: Novi Bgd.
Godina: Dipl.
Smer: IS
By balsamic vinigga in Technology
Thu Mar 16, 2006 at 07:10:44 AM EST
Tags: Software (all tags) Software


The problem with most computer science texts is the examples aren't interesting. Polymorphism isn't really hard to understand, but the examples are usually boring or difficult to understand. This is an alternative text which attempts to use a problem space that's already familiar to the college student to make the concepts of programming simple.

Pre-requisite skills You must be comfortable with classes and objects and read basic java/c# to follow this lesson.

---------------------------------------------------------------------------
----------------------------------

Polymorphism shouldn't be a new concept to anybody. You deal with it every day in the real world. There's more than one class of cat to skin, but you skin 'em the same way, even if the specific instance is completely new to you. Let's say for example you want to f**k a hole. You f**k all holes the same. You don't care if that hole happens to be a mouth, an ass, or a pussy, you're gonna f**k it the same way regardless. However, the mouth, pussy, or ass may respond differently to the fucking.

So you have a common abstract class named 'Hole' and 3 concrete classes Pussy, Ass, and Mouth which all extend from Hole:
Kod:
class Pussy extends Hole {}
class Mouth extends Hole {}
class Ass extends Hole {}


So, now let's say you have a Penis.f**k(Hole h) method. The Penis class is unconcerned about what the specific Hole instance is, it's gonna f**k it the same regardless. Specificly we thrust the Hole with a Penis until the Penis is spent. Finally, we give the hole the Penis' load.
Kod:
class Penis {
   public f**k(Hole h) {
      while(!this.isSpent) {
         h.takeAThrust(this);
         this.arousal++;
      }
      h.takeALoad(this.load);
   }
}


Now here's where polymorphism gets fun. The Hole will respond different to the thrusting and load depending on what specific type of Hole we're implementing.

First we must implement an abstract class which defines an abstract interface.
Kod:
abstract class Hole {
   public abstract void takeAThrust(Penis p);

   public abstract void takeALoad(Load l);
}


Now all that's left is the varying implementations of these methods in the seperate concrete classes. For example, an Ass' implementation of TakeAThrust could look something like:
Kod:
public void takeAThrust(Penis p) {
   if(!enoughLube && p.circumference > 6) {
      analFissureCount++;
   }
}


See, the beauty of it is... the Penis doesn't even need to know it's fucking an Ass for the Ass to behave like a proper Ass.

Now, let's see how we might implement TakeALoad differently for Mouth and Pussy:
Kod:
//in Pussy
public void takeALoad(Load l) {
//randomly determine whether to cause a pregnancy with a 10% chance...
   if(Math.randomNumber() % 10 == 0) {
      this.woman.EggFactory.getEgg().inseminate(l);
   }
}

//in Mouth
public void takeALoad(Load l) {
//50-50 chance of spitting or swallowing
   if(Math.randomNumber() % 1 == 0) {
      this.spit(l);
   } else {
      this.swallow(l);
   }
}


Putting it all together with client code

Now that we have our classes well planned out with polymorphism in mind, we can see the kind of luxury it is for the client programmer to work with.
Kod:
//create an array of 4 women
Woman[] women = new Woman[]{new Woman(), new Woman(), new Woman(), new Woman()};

//create a hole array to reference the holes of all 4 women, plus two additional holes.
Hole[] holes = new Hole[4*3 + 2];

for(int i = 0; i < women.Length; i++) {
   holes[3 * i + 0] = women[i].mouth;
   holes[3 * i + 1] = women[i].pussy;
   holes[3 * i + 2] = women[i].ass;
}

//additional holes (so the faggy programmers don't feel left out)
Man m = new Man();
holes[12] = m.mouth;
holes[13] = m.ass;

//now we loop through the holes and f**k them all with the same Penis

Penis p = new Man().penis;

foreach(Hole h in holes) {
   p.f**k(h);
}


See how easy it makes it for the client programmer?

Thank you class, any questions?

_________________
Oni hipotetički kostrukti o kojima se može govoriti kao o konzistentnim i relativno trajnim dinamičkim sistemima koji objašnjavaju veći deo procesa motivacije, obuhvatajući i ciljeve i motive kroz njihove međusobne relacije, čime se mogu uslovno..


Share on FacebookShare on TwitterShare on Google+
Vrh
 Profil  
Odgovori sa citatom  
 Tema posta:
PostPoslato: 29.09.2006. 22:36:37 
Korisnikov avatar

Pridružio se: 22.10.2004. 12:14:50
Postovi: 1481
Godina: Dipl.
Smer: IS
:respect: :lol:
Kako se ovako lako uci... :D

_________________
:zaljubljen: :srce:
We all have our time machines, don't we. Those that take us back are memories... And those that carry us forward, are dreams.


Share on FacebookShare on TwitterShare on Google+
Vrh
 Profil  
Odgovori sa citatom  
 Tema posta:
PostPoslato: 30.09.2006. 01:20:58 

Pridružio se: 12.06.2003. 11:49:19
Postovi: 1829
Godina: Dipl.
Smer: IS
Мајсторе! :clap: :jeah:

Ово је најбољи пример који сам у животу видео! :) Ово би требало уврстити у редовну наставу! Али озбиљно!


Share on FacebookShare on TwitterShare on Google+
Vrh
 Profil  
Odgovori sa citatom  
 Tema posta:
PostPoslato: 30.09.2006. 03:58:20 
Moderator
Korisnikov avatar

Pridružio se: 13.10.2003. 14:04:31
Postovi: 4555
Lokacija: At the poker table
Godina: II
Smer: IS
Kod:
//additional holes (so the faggy programmers don't feel left out)
Man m = new Man();
holes[12] = m.mouth;
holes[13] = m.ass;


:rlol: :lmao:

_________________
I know that the spades are the swords of a soldier
I know that the clubs are weapons of war
I know that diamonds mean money for this art
But thats not the shape of my heart


Share on FacebookShare on TwitterShare on Google+
Vrh
 Profil  
Odgovori sa citatom  
 Tema posta:
PostPoslato: 30.09.2006. 11:36:37 
Korisnikov avatar

Pridružio se: 07.06.2004. 15:40:38
Postovi: 355
Lokacija: NBG
Godina: Apsolvent
Smer: IS
:lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol:

:respect:

_________________
sit tight, kick back, relax and enjoy the ride!!!


Share on FacebookShare on TwitterShare on Google+
Vrh
 Profil  
Odgovori sa citatom  
 Tema posta:
PostPoslato: 30.09.2006. 12:06:16 

Pridružio se: 21.09.2005. 14:00:03
Postovi: 206
Godina: Dipl.
Smer: IS
daaaaaaaaaaaj ovo je previse

:D :lol: :lol:

:cool:


Share on FacebookShare on TwitterShare on Google+
Vrh
 Profil  
Odgovori sa citatom  
 Tema posta:
PostPoslato: 30.09.2006. 12:48:13 
Korisnikov avatar

Pridružio se: 11.12.2003. 00:09:55
Postovi: 6917
Lokacija: Beograd
Godina: Dipl.
Smer: IS
Zlajo, jel se ti to pripremaš za novu školsku godinu :lol:

Legendarno!

_________________
Svako je jutro novo ušće, poteci kao rečica.
Neka se trnje plete gušće nebo je tvoja prečica,
I zdrobi lažne dijamante ko ljusku šupljeg oraha
Nek bulevari sveta pamte muziku tvojih koraka


Share on FacebookShare on TwitterShare on Google+
Vrh
 Profil  
Odgovori sa citatom  
 Tema posta:
PostPoslato: 16.10.2006. 13:12:23 
Korisnikov avatar

Pridružio se: 24.06.2004. 12:54:04
Postovi: 439
Lokacija: Beograd
Godina: Apsolvent
Smer: IS
:taptap:

_________________
Odelo čini čoveka osim ako ga ne čini.


Share on FacebookShare on TwitterShare on Google+
Vrh
 Profil  
Odgovori sa citatom  
 Tema posta:
PostPoslato: 16.10.2006. 18:24:58 

Pridružio se: 08.03.2004. 16:10:43
Postovi: 572
Lokacija: Pančevo
Godina: Dipl.
Smer: IS
Sjajno!

_________________
>> <<


Share on FacebookShare on TwitterShare on Google+
Vrh
 Profil  
Odgovori sa citatom  
Prikaži postove u poslednjih:  Poređaj po  
Započni novu temu Odgovori na temu  [ 9 Posta ] 


Ko je OnLine

Korisnici koji su trenutno na forumu: Nema registrovanih korisnika i 2 gostiju


Ne možete postavljati nove teme u ovom forumu
Ne možete odgovarati na teme u ovom forumu
Ne možete monjati vaše postove u ovom forumu
Ne možete brisati vaše postove u ovom forumu
Ne možete slati prikačene fajlove u ovom forumu

Pronađi:
Idi na:  
Copyleft FONForum 2001-2014 | Powered by phpBB © phpBB Group