Language Bean Sheet
| Date: | 06/26/05 |
| Author: | Alexey Zinger |
| URL: | n/a |
| Comments: | 0 |
| Info: | http://bsheet.sf.net |
| Score: |
=
import java.text.*;
import zinger.bsheet.*;
import zinger.bsheet.text.*;
bottlesPat = "0#no bottles|1#one bottle|1<{0} bottles";
bottlesPatCap = "0#No bottles|1#One bottle|1<{0} bottles";
firstLineFormat = new MessageFormatBean(
"{0,choice," + bottlesPatCap + "} of beer on the wall, {0,choice," + bottlesPat + "} of beer."
);
secondLineFormat = new MessageFormatBean(
"Take one down, pass it around, {0,choice," + bottlesPat + "} of beer on the wall."
);
lastLineFormat = new MessageFormatBean(
"Go to the store and buy some more... {0,choice," + bottlesPat + "} of beer."
);
bottleCount = 99;
for(range = [a1:a300]; range.hasNext(); )
{
// first line
p = range.next();
model.setFormat(firstLineFormat, p.x, p.y);
model.setValueAt(new Object[] {bottleCount}, p.y, p.x);
// second line
--bottleCount;
p = range.next();
if(bottleCount < 0)
{
bottleCount = 99;
model.setFormat(lastLineFormat, p.x, p.y);
}
else
{
model.setFormat(secondLineFormat, p.x, p.y);
}
model.setValueAt(new Object[] {bottleCount}, p.y, p.x);
// skip a line
p = range.next();
}
Download Source | Write Comment
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments