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.

Results 1 to 6 of 6

Thread: please help me

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    3
    My Mood
    Grumpy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post please help me

    how can i implement Java class that emulates
    some of the capabilities of old terminals. Our terminal has a display (basically, a
    2-D array of characters), various buttons, and a way to dump its data to a file or to the
    screen.

    please can someone give me some hints please i really need them its my assignment m its due in few hours n i have been trying for days to do it but i couldn't

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: please help me

    Can you explain the capabilities you want to emulate?
    A text area would give you a 2D area to display on and allow input to be read.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Apr 2012
    Posts
    3
    My Mood
    Grumpy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: please help me

    the problem is im reading the assighment and im not understanding what i need to emulate
    these are some of the things that i need to have in my code hopefuly they will help ... it may seem easy to you and clear but im really bad in programming and i need to pass this course so please help

    The Button Interface
    Think of a Button as a button on the keyboard. What can you do with a keyboard button?
    For starters, you can press a button. So, let’s create the following interface:
    package auk.csis130;
    public interface Button {
    public void press();
    }


    The Terminal Class
    Fields and constructor: Our terminal emulator has (1) a two-dimensional array of
    characters that holds the content of the display, and (2) a cursor which moves around the
    screen when various keys are pressed. The constructor of the Terminal takes nothing,
    and initializes the display array and cursor position. The display array must be a 16-
    row by 32-column array of characters that initially contains the following text exactly:
    1
    2 *** SOUTHWEST TECHNICAL ***
    3
    4 CT-1024
    5
    6 TERMINAL SYSTEM
    7
    8 LETS YOU SEE UP TO SIXTEEN LINES
    9 WITH UP TO THIRTY TWO CHARACTERS
    10 ON ANY TELEVISION SCREEN -------
    11 1024 CHARACTERS OF MEMORY ON TWO
    12 PAGES. STANDARD EQUIPMENT ******
    13
    14
    15 _
    16
    The constructor initializes the cursor position so that it is at row:15 column:14 of the
    display. (If you use 0-based indices in your code, you should use row index 14 and
    column index 13.)
    2

    Inspection: The method charAt takes two integers (row and col) and returns the character
    displayed at that location. The row value is between 1 and 16 inclusive and the col
    value is between 1 and 32 inclusive.
    Dumping to an output device: The method dump takes one argument of type OutputStream
    and prints the content of the display array to that output stream. So, the
    output of this method should contain exactly 16 lines and each line should have exactly
    32 characters, regardless of the content of each line or whether things were written to it
    or not.

    4 The Keyboard Keys
    The terminal’s keyboard has many keys. We mentioned in Section 2, we will use objects
    that implement the Button interface to represent these keys. These keys fall into many
    categories, and therefore, each will be implemented using a class that does something
    slightly different in its press() method. For example, the “Home” button causes the
    cursor to go to the topmost leftmost position, so, the following code will create a terminal,
    get the home button, and press it, to cause the terminal cursor to go to the home
    position.
    Terminal t = new Terminal();
    Button clearBtn = t.getClearButton();
    clearBtn.press(); // clears the screen
    Button homeBtn = t.getHomeButton();
    homeBtn.press(); // moves the cursor to the topleft corner
    t.getCharButton(’a’).press(); // writes ’a’ and advances the cursor
    t.dump(System.out); // shows a screen containing just ’a’
    There are many different kinds of buttons and a corresponding set of methods that return
    these buttons. The methods are summarized below.
    • getClearButton(): Returns a Button that clears the entire display array. To clear
    the array, it is sufficient to place a space character in every cell in the array.
    • getHomeButton(): Returns a Button that moves the cursor to the top-left corner
    of the display. It does not change the content of the display array.
    • getCarriageReturnButton(): Returns a Button that moves the cursor to the beginning
    of the same line.
    • getLineFeedButton(): Returns a Button that moves the cursor to the next line
    without changing the column. If the cursor is already in the last line, pressing
    linefeed scrolls the display one line upwards. This causes the first line to be lost,
    the second line to become the first, etc., etc., until the 16th line to become the 15th,
    and creates a new and empty 16th line.
    • getCharButton(char x): Takes a character and returns a Button that if pressed,
    it types the given character x at the current cursor position (overwriting whatever
    was there) and advances the cursor to the right. If the cursor is already at the last
    column, it stays in the same place.
    3
    • getButton(ArrowDirection d): Takes a Direction d which may be one of UP,
    DOWN, LEFT, or RIGHT and returns a Button that moves the cursor in the given direction.
    If the cursor tries to move off the screen, it stays in the same place without
    scrolling or wrapping. The ArrowDirection must be an enum written inside
    the Terminal class. To refer to it from outside the class, you need to say Terminal.
    ArrowDirection.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: please help me

    The only thing I can recommend is to try to do the separate parts of the assignment one at a time.
    Pick a part, figure the program steps needed to do it, write the code, compile and test.
    When that works, move on to the next part.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Apr 2012
    Posts
    3
    My Mood
    Grumpy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: please help me

    ok thank you for the advice

  6. #6
    Junior Member
    Join Date
    Feb 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: please help me

    hi,

    Divide and conquer. I read your post and is too much in order to implement or search a solution.

    _______________
    Oscar Gómez
    Engineer at PSL
    PSL S.A. - CMMi 5 nearshore software development and IT outsourcing from Latin America - Home