Hi, if you're only interested in converting the Java code to Smalltalk, I would simple take one class at a time. For example, using the Glass class:<div><br class="webkit-block-placeholder"></div><div>Object subclass: #Glass
</div><div> instanceVariableNames: ''</div><div> classVariableNames: ''</div><div> poolDictionaries: ''</div><div> category: 'Adapter-Example'</div><div><br> </div><div>instance methods '
<i>initialize-release'</i></div><div><br class="webkit-block-placeholder"></div><div>initialize</div><div> content := 0.0</div><div><br class="webkit-block-placeholder"></div><div>instance methods '<i>accessing</i>
<i>' protocol</i></div><div><br class="webkit-block-placeholder"></div><div>content: anObject</div><div> content := anObject</div><div><br class="webkit-block-placeholder"></div><div>class methods '<i>class initialization' protocol
</i></div><div><i><br class="webkit-block-placeholder"></i></div><div><i>new</i></div><div><i> ^super new initialize</i></div><div><i><br class="webkit-block-placeholder"></i></div><div>Good luck,</div><div><br class="webkit-block-placeholder">
</div><div>-Conrad</div><div><br> </div><div><div><span class="gmail_quote">On 8/29/07, <b class="gmail_sendername">KingNothing</b> <<a href="mailto:petpa0l0@hotmail.com">petpa0l0@hotmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>Hi, i'm new to this forum and to smalltalk.<br>I've got to implement now the Adapeter Pattern in SmallTalk.<br>I've got an example in Java that i must translate in SmallTalk.<br>Here there are the Java Classes :
<br><br>------------------------------------------<br>public class Glass<br>{<br> /**<br> in 12th of pint<br> */<br> float content;<br><br> public Glass()<br> {<br> content=0;<br> }<br><br> /**<br>
*/<br> public void fill(float filling)<br> {<br> content=filling;<br> }<br><br> public String toString()<br> {<br> return<br> super.toString()+<br> ", level (12th of pint)="+content;
<br> }<br>}<br>-------------------------------<br><br>public class Keg<br>{<br> /**<br> content, in 12th of pint units<br> */<br> float filled;<br><br> /**<br> absolute level, in pints<br> */<br> public float getLevel()
<br> {<br> return filled/12;<br> }<br><br> float original;<br> /**<br> in pints<br> */<br> public float getCapacity()<br> {<br> return original/12;<br> }<br><br><br> /**<br> Keg filled with total gallons of beer
<br> */<br> public Keg(float total)<br> {<br> filled=total*8*12;<br> original=filled;<br> }<br><br> /**<br> creates a Glass filled with<br> quantity/12 pints of beer<br> */<br> public Glass draw(float quantity)
<br> {<br> Glass g=new Glass();<br> g.fill(quantity);<br> filled-=quantity;<br> return g;<br> }<br><br> /**<br> % level<br> */<br> public float getPLevel()<br> {<br> return (100*filled)/original;
<br> }<br><br> public String toString()<br> {<br> return<br> super.toString()+<br> ", level (%)="+getPLevel()+<br> ", level (pints)="+getLevel();<br> }<br>}<br>------------------------------
---<br><br>public class Fusto<br>{<br> /**<br> rapporto LITRO/PINTA<br> */<br> public final static float LITRO_PINTA=2.1133f;<br><br> Keg keg;<br> public Fusto(Keg k)<br> {<br> keg=k;<br> }<br><br>
/**<br> crea un Glass riempito con<br> quant/10 litri di birra<br> */<br> public Glass spilla(float quant)<br> {<br> return keg.draw(quant*LITRO_PINTA*12/10);<br> }<br><br> /**<br> in litri, NON in percentuale!!!
<br> */<br> public float fornisciLivello()<br> {<br> return keg.getLevel()/LITRO_PINTA;<br> }<br><br> /**<br> in percentuale<br> */<br> public float fornisciPLivello()<br> {<br> return keg.getPLevel
();<br> }<br><br> public String toString()<br> {<br> return<br> super.toString()+<br> ", livello (%)="+fornisciPLivello()+<br> ", livello (litri)="+fornisciLivello();
<br> }<br>}<br>-------------------------------------<br><br>Can someone give me some hints to translate java code into SmallTalk ?<br>Thanks in advance.<br><br>--<br>View this message in context: <a href="http://www.nabble.com/Adapter">
http://www.nabble.com/Adapter</a>-Pattern-in-SmallTalk-tf4347089.html#a12384904<br>Sent from the Squeak - Beginners mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br><br>______________________________
_________________<br>Beginners mailing list<br><a href="mailto:Beginners@lists.squeakfoundati">Beginners@lists.squeakfoundati</a><a href="http://on.org">on.org</a><br><a href="http://lists.squeakfoundation">http://lists.squeakfoundation
</a>.org/mailman/listinfo/beginners<br></blockquote></div><br></div>