Sorry, my mistake on the abstract thing - I don't write many abstract classes.
I think you're looking for the "protected" and "static" class modifers:
This would allow any class inheriting the above to change the getWordList
method for it's own use.
Question: why would you want to pass in an alphabet? Why not keep everything
in a single class with static modifiers? (excuse me if I don't have all of the
java syntax exactly right)
public static class AlphaSet_lapd extends AlphaSet
{
protected static String[] getWordList()
{
String[] WordList =
{
"Adam","Boy","Charles","David","Edward","Frank","George","Henry","Ida","John",
"King","Lincoln","Mary","Nora","Ocean","Paul","Queen","Robert","Sam","Tom",
"Union","Victor","William","X-ray","Young","Zebra"
};
return WordList;
};
}
public static class AlphaSet
{
public static void setOutputStyle (string style)
{
//do something
}
public static void setOutputPostfix (string postfix)
{
//do something
}
}
AlphaSet_lapd.setOutputStyle("Verbose");
AlphaSet_lapd.setOutputPostfix("\n");
//Translate (and output) a phrase
System.out.println(AlphaSet_lapd.translateToString("I know Java!"));
Let me know if there's anything wrong with this.
- Matt Small
>> -----Original Message-----
>
>You can defiantly create methods in abstract classes - that's what I ended
>up doing. ;^)
>
>If the method itself is marked "abstract" then you can't provide a body for
>the method (basically acting just like an interface) but if the method is
>marked as anything else then you can create it as you would normally.
>
>I don't know if this is at all "correct" - but this how I ended up:
>
>Two main objects:
>
>AlphaWords:
>
>Public class. The class has lots of properties accessed via setters/getters
>that affect the output of the class (OutputPrefix, OutputPostfix,
>OutputIncludeCSS, CharCSS and TransCSS).
>
>One property takes a "WordList" which is of type "AlphaSet" as does the
>constructor: public AlphaWords(AlphaSet NewAlphaSet).
>
>This class accepts a string and outputs formatted work lists.
>
>
>
>AlphaSet:
>
>Abstract class. This class represents a word substitution list.
>
>It has one abstract class, getWordList(), which returns the word
>substitution list (provided by sub classes) and one public class,
>getCharTrans(CharCode), which takes an ASCII code and returns the
>substituted word/phrase (or a null for those cases when there is no
>translation).
>
>It has one private method, setTransTable(), which takes the word list and a
>whole mess of standardized symbol translations and creates an array of
>words/phrases who's indexes match the ASCII character code.
>
>
>
>Alphabets:
>
>Alphabets are generated by extending AlphaSet and implementing
>getWordList(). Here's a complete AlphaSet:
>
>package com.depressedpress.alphaWords;
>
>public class AlphaSet_lapd extends AlphaSet {
>
> public String[] getWordList() {
> String[] WordList =
>{"Adam","Boy","Charles","David","Edward","Frank","George","Henry","Ida","Joh
>n","King","Lincoln","Mary","Nora","Ocean","Paul","Queen","Robert","Sam","Tom
>","Union","Victor","William","X-ray","Young","Zebra"};
> return WordList;
> };
>
> public AlphaSet_lapd() {
> super();
> }
>
>}
>
>
>A simple implementation of all this might look like this:
>
> // Instantiate AlphaWords with the "nato" alphabet
>AlphaWords aw = new AlphaWords(new AlphaSet_nato());
> // Set some properties for the output
>aw.setOutputStyle("Verbose");
>aw.setOutputPostfix("\n");
> // Translate (and output) a phrase
>System.out.println(aw.translateToString("I know Java!"));
>
>This would output:
>
>Uppercase "I" as in India
>The Space symbol (" ")
>Lowercase "k" as in Kilo
>Lowercase "n" as in November
>Lowercase "o" as in Oscar
>Lowercase "w" as in Whiskey
>The Space symbol (" ")
>Uppercase "J" as in Juliett
>Lowercase "a" as in Alfa
>Lowercase "v" as in Victor
>Lowercase "a" as in Alfa
>The Exclamation Point symbol ("!")
>
>
>Again I'm not sure that I like this... I don't like the "getWordList()"
>method being public but Java doesn't expose "private" methods to children
>and abstract methods can't be private anyway.
>
>Since it also doesn't expose private variables to children in any way that
>they can be overridden the only real option seems to be to make things
>public.
>
>How would you encapsulate a set of objects that only changed in the instance
>data but where you wanted the instance data to be static? I'm sure there's
>a better way than I've done.
>
>(I also did a "single class" version where all the alphasets were just
>embedded in the main class. It works just fine but any additional alphasets
>require modification of the main code - not really OO.)
>
>Jim Davis
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 by AdobeĀ®
Dyncamically transform webcontent into Adobe PDF with new ColdFusion MX7.
Free Trial. http://www.adobe.com/products/coldfusion?sdid=RVJV
Archive:
http://www.houseoffusion.com/groups/CF-Community/message.cfm/messageid:232041
Subscription: http://www.houseoffusion.com/groups/CF-Community/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.5