Lab3RemoteTherapist

Lab3RemoteTherapist - ECE309 Lab 3 RemoteTherapist(Spring...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE309 Lab 3 - RemoteTherapist (Spring 2010)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Due midnight Thursday January 28 Overview This program has the same function as the previous lab (TherapistGUI) as far as the user is concerned. It just interfaces to the therapist in a remote computer. This is, finally, a realistic situation! For our development we will modify lab 2 TherapistGUI to become our lab 3 TherapistClient , and we will modify our lab 1 Therapist program to become our lab 3 TherapistServer ! Although the client and server programs are designed to run in different computers, you can test them in the same computer by simply starting them in different DOS windows. Every time we initiate a Java program from a DOS window, we are executing java.exe which is the JVM! So you can easily run multiple JVMs on the same computer, and programs running in separate JVMs communicate with each other just like they would when the JVM is in another computer. Teaching Points: Socket communications using command line parameters multiple ("overloaded" constructors) calling constructors from constructors throwing and catching exceptions References for Java concepts used in this lab See Sockets.html in the JavaNotes directory at http://courses.ncsu.edu/ece309/common
Background image of page 2
In the Java tutorial trails at http://java.sun.com/docs/books/tutorial, see the "Custom Networking" trail's "All About Sockets" section. See "Overloading Methods" in Lecture4 in the JavaNotes directory of ECE309/common on Wolfware. Part 1 - The client-side program TherapistClient The TherapistClient program presents a graphics window to accept user questions and send them to the TherapistServer program in a remote computer. It then receives an answer from the therapist and displays it on the GUI. 1. Begin by copying TherapistGUI.java in your Java directory as TherapistClient.java . 2. On the class declaration line of TherapistClient, change the class name from TherapistGUI to TherapistClient. 3. In the TherapistClient, at the top of the program where you're declaring the window, change the JFrame constructor parameter to "Therapist Client". (Now when you're testing this lab, you can verify that you're in fact running TherapistClient rather than TherapistGUI by mistake!) 4. In TherapistClient, remove the declaration of the reply array (We'll be getting the answers from the remote therapist now!). 5. In the actionPerformed() method of TherapistClient, in the block of code that services the questionTextField, change the line
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
String answer = reply[(int)(Math.random() * reply.length)]; to String answer = "got me!; and precede that with the comment line // Call ClientServer followed by some blank lines for now. This is where our new code will go. We will open a connection to the server here, send the question, and receive a reply. We will then show that reply to the user on the GUI, instead of picking one from the reply array like we used to in TherapistGUI. But first, we have to add a parameter to our constructor so we will
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/25/2010 for the course ECE 309 taught by Professor Bowman during the Spring '09 term at N.C. State.

Page1 / 26

Lab3RemoteTherapist - ECE309 Lab 3 RemoteTherapist(Spring...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online