"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Originally posted by Michael Dunn:
see if you can follow this
That is the default behavior of toString() defined in Object. The hexadecimal (base 16) number after the "@" is a hash of the object's address. You don't need to understand what the hash means, just that it's not entirely useful for your current needs.Originally posted by black-drop:
oh well i tried it and it didnt work. It prints out something like
PronunciationDictionary@1ea2dfe
or
PronunciationDictionary@cac268
PronunciationDictionary is the name of my main class.
You can edit your posts using the pencil and paper icon above the individual post. Try to use it only to fix posts (formatting, wording, etc.) rather than ask new questions or delete questions that have been answered, otherwise the thread is impossibly difficult to follow.Originally posted by black-drop:
Woops sorry i didnt mean to paste all that..
Originally posted by Krit c.:
There
Would that qualify as a valid name?
Simply have it call through the PronunciationDictionary class:I assume PronunciationDictionary has a static reference to whatever object it is that you're creating and the static toString() method.Originally posted by black-drop:
I did manage to get it to work when the toString was called from the main class as you told me, but how will i make it work when it is called from a third class?
Originally posted by Ernest Friedman-Hill:
Closer, but no initials, please. Thanks.
Originally posted by David Harkness:
I assume PronunciationDictionary has a static reference to whatever object it is that you're creating and the static toString() method.
Originally posted by Krit c.:
hmm but the naming policy sais "You can even use initials for the first name if you like." !!
Originally posted by Ernest Friedman-Hill:
Indeed. Which means that you can't use an initial for your last (second) name.
Just like static methods, you don't need an instance of the class to access it. As well, static methods have access to static fields of the same class. Search this forum for "static instance method" and you should get some hits. It is discussed every couple of weeks.Originally posted by Krit Christoforou:
What's the difference of a static variable from an "ordinary" variable?
TreeMap implements the Map interface which defines get() and put() and other methods. Map of course extends Collection which defines size() and other methods.Originally posted by Krit Christoforou:
How can i get something i previously stored from a treeset since it has no get() method?
Originally posted by David Harkness:
You explanation makes great sense. From it I would say that the PronunciationDictionary class should manage the TreeSets or other collections. Those collections would hold instances of the classes that represent individual words and their pronunciations.
Please elaborate on this a bit after reading my first paragraph. I think you understand, but I need a more detailed description -- better, code.When i call contains ie on Orthography, and i say myString.Contains("Test") ,it should test if myString contains test?
Originally posted by David Harkness:
For this exercise, using static variables will certainly work. However, in object oriented software, it's best to create objects that have instance members...
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
When it comes to the Pronunciation class, I don't think you can treat them as a String because I believe each phoneme should be treated as a character. For example, I suspect the Pronunciation.isMinimalPair(Pronunciation) method should return true for the phonemes for "abanden" and "abandon" even though they differ by two characters but only differ by one phoneme.
Arthur, where are your pants? Check under this tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|