What design pattern should I use for specific multiple inheritance?
DynamicSquid

Let's say I have an interface called Squid.

And we have a bunch of different types of squids:

Here's everything a squid can be:

aquaticland
basicbasic-aquaticbasic-land
advancedadvanced-aquaticadvanced-land

How would I go about create an instance of a squid? Should I go about creating 4 classes BasicAquaticSquid, BasicLandSquid, AdvancedAquaticSquid, AdvancedLandSquid like this:

I think that's called the Abstract Factory method? It seems very tedious though. Any better way of doing so?

Thanks

You are viewing a single comment. View All
Answered by xxpertHacker [earned 5 cycles]
View Answer
Coder100

for others, i made a tiny table:

well that's just great tables aren't supported no more
well that's just great i forgot how to do tables

DynamicSquid

@Coder100 wait I though tables didn't work here

Coder100

apparantly my brain broke @DynamicSquid

Coder100

anyways check out the other comment imma try to think of how to solve your problem @DynamicSquid

DynamicSquid

@Coder100

VersionDescriptionProgress
v1.0functions to aid with arrayscomplete
DynamicSquid

@Coder100 oh ok nvm they work

Coder100

anyways check out my answer is it even good @DynamicSquid

Coder100

hol' up i thought this was C++, and then i looked at the interface and I was like oh wait nvm @DynamicSquid

DynamicSquid

@Coder100 it doesn't matter what language it is

Coder100

ig
did it help tho @DynamicSquid

Coder100

@DynamicSquid that would be pog if my ideas actually came to life :D

DynamicSquid

@Coder100 But in your example you combined Swim and Crawl, but they need to be separate functions

Coder100

wait but you could add if statements:

@DynamicSquid

DynamicSquid
Coder100

wait why not @DynamicSquid

firefish

@DynamicSquid lol le sqdlib (also come onto le pr #65 on NIGHT)

firefish

@Coder100 No if statements, THIS IS A FLIPPING INTERFACE, you can implement them how you want, so move() does different things depenfing on whether it's land or water