Hellfire103@lemmy.ca to Programmer Humor@lemmy.mlEnglish · 5 个月前TIFU by not using objects in my object-oriented programming courseworklemmy.caimagemessage-square24fedilinkarrow-up179arrow-down110cross-posted to: [email protected][email protected]
arrow-up169arrow-down1imageTIFU by not using objects in my object-oriented programming courseworklemmy.caHellfire103@lemmy.ca to Programmer Humor@lemmy.mlEnglish · 5 个月前message-square24fedilinkcross-posted to: [email protected][email protected]
minus-squarevext01@lemmy.sdf.orglinkfedilinkarrow-up12arrow-down1·5 个月前Balls.suck() is the correct syntax.
minus-squareRagingToad@feddit.nllinkfedilinkarrow-up4·5 个月前Don’t you need to declare new Balls() first? Or do you suck() Balls static?
minus-squarexigoi@lemmy.sdf.orglinkfedilinkEnglisharrow-up8·edit-25 个月前BallsFactory ballsFactory = new BallsFactory(); ballsFactory.setSuckable(true); Balls balls = ballsFactory.create();
minus-squarewhats_all_this_then@lemmy.worldlinkfedilinkarrow-up11·edit-25 个月前All of this is okay, but it’s not production ready. This is what real production code looks like: SuckableFactory suckableFactory = new SuckableFactory(); Suckable balls = suckableFactory .setShape(SuckableShapes.round) .setCount(2) .create(); SuctionProvider mouth = SuctionProvider.getInstance(); SuckerFactory suckerFactory = new SuckerFactory(); Sucker sucker = SuckerFactory.create(): sucker.setSuctionProvider(mouth); sucker.setSuckable(balls); sucker.setIntensity(SuckerSuctionIntensities.medium); sucker.suckSuckable();
minus-squarewhats_all_this_then@lemmy.worldlinkfedilinkarrow-up14·5 个月前Python port: from ballsucker import suck suck()
minus-squarevext01@lemmy.sdf.orglinkfedilinkarrow-up3·5 个月前Or I didn’t using the correct naming convention!
minus-squareluciferofastora@lemmy.ziplinkfedilinkarrow-up2·5 个月前Actually, it would be OOP.suck(ddplf.getBalls())
Balls.suck() is the correct syntax.
Don’t you need to declare new Balls() first? Or do you suck() Balls static?
BallsFactory ballsFactory = new BallsFactory(); ballsFactory.setSuckable(true); Balls balls = ballsFactory.create();
All of this is okay, but it’s not production ready. This is what real production code looks like:
SuckableFactory suckableFactory = new SuckableFactory(); Suckable balls = suckableFactory .setShape(SuckableShapes.round) .setCount(2) .create(); SuctionProvider mouth = SuctionProvider.getInstance(); SuckerFactory suckerFactory = new SuckerFactory(); Sucker sucker = SuckerFactory.create(): sucker.setSuctionProvider(mouth); sucker.setSuckable(balls); sucker.setIntensity(SuckerSuctionIntensities.medium); sucker.suckSuckable();
Python port:
from ballsucker import suck suck()
Or I didn’t using the correct naming convention!
Actually, it would be
OOP.suck(ddplf.getBalls())