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 5 of 5

Thread: Modification of chat client program

  1. #1
    Junior Member
    Join Date
    May 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Modification of chat client program

    I have been given an assignment which i pretty much don't understand and i need your help please

    this is the question. (There's a zip file that contains the code to be modified)

    a) Extend the chat client as described above so that if a message contains the string ".mp3" this will be replaced by a music icon. For simplicity you ma y assume that this string will never appear twice in the same message,
    or occur in the same message as the string that will be replaced by a smiley.

    b) , change the client code to point to the URL of the remote chat server at The Open University, and have a conversation with a fellow student or students.
    So you are likely to have someone to talk to when you connect to the server, we suggest t hat you try between 5 pm and 1 0pm, during the weeks 19 April to 26 April or 14 June to 21 June. If you cannot make these times then you can use the M362 discussion forum on FirstClass to arrange to meet a fellow student at a more convenient time.
    In your Solutions Document include a screenshot showing a chat conversation with a fellow student and demonstrating that the music icon is correctly displayed.
    Attached Files Attached Files


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Help need please

    Hello YannStacy,

    Have you attempted any of this yet?

    The first thing to do is to extract the files from the zip archive and load the source files into your IDE.

    Create a new project called 'TMA02Q1a', add a new package called 'guiclient' then put all the .java files into TMA02Q1a\src\guiclient.

    Make sure the other nbproject dir & xml files are in the root of your new project. In exactly the same structure as the zip.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Help need please

    Extend the chat client as described above
    Where is the rest of the assignment information?

    I've had a quick look through the code. This is either going to be for the String message or String newmessage. You need to add an if statement something like:

    if(message.contains(".mp3")){
    //code to print mp3 icon
    }
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  4. #4
    Junior Member
    Join Date
    May 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help need please

    yeah i looked through the code and also your suggestion.

    but i still don't get how to make this icon appear and where exactly add that if statement

  5. #5
    Junior Member
    Join Date
    May 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help need please

    /*
     * ChatClientImpl.java
     *
     * Created on 06 February 2007, 23:15
     *
     */
     
    package guiclient;
     
    //import java.awt.event.*;
    //import javax.swing.*;
    //import java.io.*;
    //import java.net.*; 
     
    /**
     *
     * @author m362 Course Team
     */
    public class ChatClientImpl implements ChatClient
    {
       ChatRoom room;
       GUIChatFrame frame;
     
       public ChatClientImpl(ChatRoom room)
       {
          this.room = room;
          frame = new GUIChatFrame(room, (ChatClient) this);
          frame.setTitle("M362 Chat Room");
          frame.setVisible(true);
          frame.setAlwaysOnTop(true);
       }
     
       public void output(String newmessage)
       {
          if (frame == null)
             return;
          frame.setOutputText(newmessage);
       }
     
       public void run()
       {
          if (room == null)
             return;
          while (true)
          {
             try
             {
                String newmessage = room.receive();
                if (newmessage != null)
                {
                   if (!newmessage.equals(""))
                      output(newmessage);
                }
             }
             catch (Exception e)
             {
                System.out.println("Communication problem");
             }
          }
       }
    }

Tags for this Thread