It's a utility class that was already created
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
It's a utility class that was already created
That doesn't make any difference. You still need to know how to use its methods.
Is getLetter() a method in the LEDFont class?
The LEDFont class that is already compiled does not have a source code so I can't view anything in it.
If you don't have any documentation on how to use the LEDFont class it will be VERY DIFFICULT to use it.
You must have documentation.
That's why I'm having a mare with it
Who suggested you use a class with no documentation?
Nope, there's no doc with it. I'll paste the question to give you a better understanding.
Write a public instance method called writeLetter() which takes a single argument
of type char called aCharacter and returns no result. The method should first invoke
the getLetter() method on the LEDFont class with aCharacter as its argument. As
stated earlier, getLetter() returns a two-dimensional array of type boolean which
has has FONT_LETTER_HEIGHT rows and FONT_LETTER_ WIDTH columns,
representing the LED settings for aCharacter. The array should be assigned to an
appropriately declared local variable called letter. The method should then copy the
boolean values from letter into matrix starting at the first row and column,
overwriting existing values.
Test your code in the OUWorkspace as follows:
LEDDisplay led = new LEDDisplay();
led.writeLetter('W');
led.display();
If your code is correct, you should see the pattern for the 'W' in the Display Pane as
shown in Figure 4. If you don’t, or if the JVM throws an array exception, check that you
have the rows and columns the right way round. Note that sending subsequent
writeLetter() messages to led will overwrite the existing letter in matrix. This
limitation will be dealt with later.
Figure4The project contains a utility class called LEDFont which encodes alphabetic characters and
the space character into two-dimensional arrays of boolean values. (Note there is no source
code available for this class, only the compiled class.) When the class method getLetter()
is invoked on LEDFont with a single letter in uppercase or lowercase (or a space character)
as the argument, it returns a two-dimensional array (5 rows and 6 columns) of boolean
values representing this letter in uppercase (or a space character).
Sorry, I don't feel like going through your assignment. Your teacher must expect you to be able to understand it. If not, go ask him about the parts you don't understand.
Very well.
The assignment instructions you posted tell you what method to call on the LEDFont class, what argument it takes, and what it returns. That's enough documentation to use it. What's the problem?
I have done this so far
public void writeLetter(char aCharacter) { boolean letter[][] = LEDFont.getLetter(aCharacter); }
and I'm just stuck on what I need to put for my getLetter method, as I need to try and override the original array
Hey eNxy, out of pure interest did you sort out the first problem you had with the implementing the boolean array? Its just im having a similar problem and I just cant work it out!
I just want it to output '.' if any of the 2 dim array elements are false and 'O' if any are true, but it wont let me! So it looked like you got it!
Regards
Yep, I got the first part and it displays the lines
The convention is to declare arrays of a type with the square brackets associated with the type rather than the variable:
boolean[][] letter = ...
That doesn't make sense to me - what do you mean by 'override the original array' ?I'm just stuck on what I need to put for my getLetter method, as I need to try and override the original array
The first part was to create a 2D Boolean array called matrix. The array dimensions of matrix is equal to the local variable letter and the method I have to write should copy the boolean values of letter into the matrix array I created earlier.
Apologies for the array letter code. I had actually written boolean[][] letter = .... as soon as I sent the message :-)
So you have to copy the contents of the 2D letter array into the 2D matrix array? Why not just use the 2D letter array?
If you have to do a copy, you can use a single loop to copy the row arrays directly, or a nested loop if you need to copy the individual elements of each row.