1 / 1

Managing Drink Volumes and States in Java Classes

This Java code snippet demonstrates object-oriented programming concepts by managing different drink containers and their states. It utilizes classes like `CupO` and `MugO`, illustrating how to create instances of drink containers, fill them, and handle their volumes. The interaction between different drink objects, such as `PaperCupQ`, is shown by invoking methods to drink specific amounts and check their statuses. The code also highlights the relationships between drinkers and their chosen containers in a fun, party-themed scenario.

nova
Télécharger la présentation

Managing Drink Volumes and States in Java Classes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CupO ratio 0.8 CupO.setRatio(Float.parseFloat(arg[0]); MugO m1 = new MugO(); volume 250 p1 = new PaperCupQ('B'); MugO c1 = new PaperCupQ("Cindy"); amount 195 PaperCupQ m1.fill().drink(); drinker '?' volume 150 p1.drink(20); mthd stack p2.drink(); PaperCupQ PaperCupQ amount amount 115 100 m1 M drinker drinker 'C' 'B' p1 P c1 C times times 1 1 this C drinker drinker null this this this this this C P P P P this this C C String "Cindy" this this C C Animation of PartyQ … m1.status() … … amount … drinker … … p1.status() … super.status(); … amount … drinker … … times … drinker … … c1.status() … super.status(); … amount … drinker … … times … drinker …

More Related