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.

Page 2 of 2 FirstFirst 12
Results 26 to 41 of 41

Thread: Implementing a two-dimensional boolean array

  1. #26
    Junior Member
    Join Date
    Jul 2011
    Posts
    20
    My Mood
    Angry
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Implementing a two-dimensional boolean array

    It's a utility class that was already created

  2. #27
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Implementing a two-dimensional boolean array

    That doesn't make any difference. You still need to know how to use its methods.
    Is getLetter() a method in the LEDFont class?

  3. #28
    Junior Member
    Join Date
    Jul 2011
    Posts
    20
    My Mood
    Angry
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Implementing a two-dimensional boolean array

    The LEDFont class that is already compiled does not have a source code so I can't view anything in it.

  4. #29
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Implementing a two-dimensional boolean array

    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.

  5. #30
    Junior Member
    Join Date
    Jul 2011
    Posts
    20
    My Mood
    Angry
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Implementing a two-dimensional boolean array

    That's why I'm having a mare with it

  6. #31
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Implementing a two-dimensional boolean array

    Who suggested you use a class with no documentation?

  7. #32
    Junior Member
    Join Date
    Jul 2011
    Posts
    20
    My Mood
    Angry
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Implementing a two-dimensional boolean array

    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.
    Figure4
    The 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).

  8. #33
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Implementing a two-dimensional boolean array

    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.

  9. #34
    Junior Member
    Join Date
    Jul 2011
    Posts
    20
    My Mood
    Angry
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Implementing a two-dimensional boolean array

    Very well.

  10. #35
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: Implementing a two-dimensional boolean array

    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?

  11. #36
    Junior Member
    Join Date
    Jul 2011
    Posts
    20
    My Mood
    Angry
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Implementing a two-dimensional boolean array

    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

  12. #37
    Junior Member
    Join Date
    Jul 2011
    Posts
    8
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Implementing a two-dimensional boolean 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

  13. #38
    Junior Member
    Join Date
    Jul 2011
    Posts
    20
    My Mood
    Angry
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Implementing a two-dimensional boolean array

    Yep, I got the first part and it displays the lines

  14. #39
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: Implementing a two-dimensional boolean array

    Quote Originally Posted by eNxy View Post
    I have done this so far
         public void writeLetter(char aCharacter)
         {
             boolean letter[][] = LEDFont.getLetter(aCharacter);
         }
    The convention is to declare arrays of a type with the square brackets associated with the type rather than the variable:

    boolean[][] letter = ...

    I'm just stuck on what I need to put for my getLetter method, as I need to try and override the original array
    That doesn't make sense to me - what do you mean by 'override the original array' ?

  15. #40
    Junior Member
    Join Date
    Jul 2011
    Posts
    20
    My Mood
    Angry
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Implementing a two-dimensional boolean 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 :-)

  16. #41
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: Implementing a two-dimensional boolean array

    Quote Originally Posted by eNxy View Post
    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.
    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.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Problem printing a two dimensional boolean array
    By sallyB in forum What's Wrong With My Code?
    Replies: 10
    Last Post: June 23rd, 2011, 03:56 PM
  2. Two-dimensional boolean array?
    By tcmei in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 17th, 2011, 08:32 PM
  3. Single Dimensional Array Help!
    By Allicat in forum What's Wrong With My Code?
    Replies: 6
    Last Post: March 15th, 2011, 12:01 PM
  4. Two-Dimensional Array and Loops
    By astrojunk in forum Java Theory & Questions
    Replies: 2
    Last Post: February 11th, 2011, 07:18 AM
  5. 2 dimensional array alternative ???
    By zeeshanmirza in forum Java SE APIs
    Replies: 1
    Last Post: February 23rd, 2010, 06:18 PM