From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f7344,8be18979db11f51c X-Google-Attributes: gidf7344,public X-Google-Thread: 1164f8,fb631c9316319fef X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 2001-02-28 18:46:03 PST Path: supernews.google.com!sn-xit-03!supernews.com!freenix!isdnet!newsfeed.online.be!newsfeed1.news.nl.uu.net!sun4nl!not-for-mail Message-ID: <3A9DB7F8.F3208083@infopuls.com> Date: Thu, 01 Mar 2001 02:46:17 +0000 From: Christof Brass Organization: InfoPuls X-Mailer: Mozilla 4.73 [en] (X11; U; Linux 2.0.36 i586) X-Accept-Language: de MIME-Version: 1.0 Newsgroups: comp.os.vms,comp.sys.dec Subject: Re: Drop C/C++ better sooner than later References: <87n1baae6s.fsf@prep.synonet.com> <97bm3a$7tv@gap.cco.caltech.edu> <3A99AED0.5DF07890@infopuls.com> <97cd06$hcn$1@pyrite.mv.net> <97egck$vc6$3@info.cs.uofs.edu> <3A9AEFCD.AFC8431@infopuls.com> <97etsu$j41$1@pyrite.mv.net> <3A9B023A.CBD414A5@infopuls.com> <97hvro$hj4@freepress.concentric.net> <3A9CA5B0.3614CAE7@videotron.ca> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cache-Post-Path: fuchs.cyberlink.ch!unknown@193.247.146.165 X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/) NNTP-Posting-Host: 193.246.253.18 X-Trace: 983414652 news.ch.uu.net 177 193.246.253.18 Xref: supernews.google.com comp.os.vms:20635 comp.sys.dec:2947 JF Mezei wrote: > > re: switch / case: > > I have had occasions where I did make use of the lack of automatic "break" at > the end of a case statement. > > Think of a dishwasher: > > switch(wash_type) > { > case heavy_duty: > fill_tank(); > wash(5 minutes, no_soap, no_rinse_agent); > empty_tank(); > case very_dirty: > fill_tank(); > wash(5 minutes, no_soap, no_rinse_agent); > empty_tank(); > case regular: > fill_tank(); > wash(10 minutes, soap, no_rinse_agent); > empty_tank(); > > case rinse: > fill_tank(); > wash(10 minutes, no_soap, rinse_agent); > empty_tank(); > dryer(15 minutes); > break; > > case rinse_only: > fill_tank(); > wash(5 minutes, no soap, no rinse agent); > empty_tank(); > break; > > case dish_warmer: > dryer(5 minutes); > break; > > So, in the case of a heavy_duty wash, it will fall down all the way to the end > of the rinse and then stop. CLASS Dishwasher; CONSTANT soap = TRUE; no_soap = FALSE; rinse_agent = TRUE; no_rinse_agent = FALSE; METHOD fill_tank(); METHOD empty_tank(); METHOD wash(min: Minutes; soap: BOOLEAN; rinse_agent: BOOLEAN); METHOD rinse(); BEGIN fill_tank(); wash(10, no_soap, rinse_agent); empty_tank(); dryer(15 minutes) END rinse; METHOD regular(); BEGIN fill_tank(); wash(10, spoap, no_rinse_agent); rinse(); END regular; METHOD very_dirty(); BEGIN fill_tank(); wash(5, no_spoap, no_rinse_agent); empty_tank(); regular(); END very_dirty; METHOD heavy_duty(); BEGIN fill_tank(); wash(5, no_spoap, no_rinse_agent); empty_tank(); very_dirty(); END heavy_duty; METHOD rinse_only(); BEGIN fill_tank(); wash(5, no soap, no rinse agent); empty_tank() END rinse_only; METHOD dish_warmer(); BEGIN dryer(5) END dish_warmer; END Dishwasher; Exercise 1: Introduce a seventh mode of operation called "Machine cleaning" ... Exercise 2: Change *only* regular() in that it washes 12 minutes. The other mode should operate as before.