jon ladd

Ranch Hand
+ Follow
since Feb 11, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by jon ladd

This is a client server program. First you have to laod the server, create a file for the has map to write to then start the client portion. Once the client is running when i type in a name and try to add a name and number it just says invalid number. It not writing from the client server. Any ideas on why it is not doing that would be very helpful.

18 years ago
You must look at it differntly i make chages i just get more errors
18 years ago
Ok i am trying to get my add button working I had it compiling but now it just keep blowing up and I have no idea. I redid the code form the first example, for the most part.
18 years ago
Thanks for taking the time to look at it
18 years ago
I know this is alot but I am stuck, the code below is what I have come up with so far from are instructor example, any Ideas, or correction would be greatly appreceiated.
Requirements:
In a single source file named App.java, define a public class named App that can be run as either a multithreaded Windows server or as a Windows client to process a telephone directory. Two other non-public classes must also be defined. One, named Person, will encapsulate the data and processing of a person. The other, named ServerThread, will define the processing of a server thread for each client.
The server (via its threads) will handle client requests to add, find, and delete Person objects maintained within a HashMap using the person's name as the key. It must store the HashMap to disk when it is shutdown and reload the HashMap from disk when it is restarted.
The client will provide a GUI front-end for adding, finding, and deleting Person objects.
Define a serializable Person class outside of the App class. It must only encapsulate name (String) and phone number (String). Code a single constructor to instantiate an object using values received for both instance variables. Provide simple "set" and "get" methods (setName(), getName(), etc.) to store and retrieve the value of each instance variable. Do NOT be concerned with editing the values of the instance variables.
Define the App class for a Windows program that will immediately ask the user to specify the processing mode (client or server). The technique for determining the processing mode is up to you (Choice, Checkbox, Buttons, etc.). Based upon the mode, processing is as follows:
Server processing
Using a FileDialog, ask the user for the name and location of the telephone directory file. If the specified file has a length other than zero, read it as a HashMap. Otherwise, instantiate a new HashMap for the telephone directory.
Loop to accept client logins. When one occurs, construct a new ServerThread with references to its Socket and the HashMap. Then, call the thread's start() method to begin its processing.
When the Window is closed, destroy all threads and write the HashMap to disk.
ServerThread processing
During construction, establish an ObjectInputStream and an ObjectOutputStream for the socket.
The run() method must handle client requests to add a Person to, find a Person in, or delete a Person from the HashMap. Develop your own scheme for transaction codes but be sure to:
Send a String object to the client indicating the success or failure of an add or delete transaction. For example, "person added", "person already exists", "person deleted", or "person not found".
Send a Person object to the client for a find transaction. If the person was not found within the HashMap, send a Person object having null values for name and phone number. Otherwise, send the found Person object.
Synchronize code to prevent two threads from working with the HashMap at the same time.
Provide a destroy() method to kill the thread.
Client processing
Provide a GUI with text fields for entering and displaying the person's name and phone number. Use buttons to trigger Add, Find, and Delete operations, and a text field or text area for displaying messages. The Delete button should only be enabled after a Find operation has succeeded. The choice of layout, colors, and fonts are up to you.
When Add is selected, verify that all data is present. If it is, construct a Person object, send it to the server as part of an add transaction, and read and display the server's reply. If not all data is present, send nothing to the server but display an error message.
When Find is selected, verify that the person's name is present. If it is, send the person's name to the server as part of a find transaction, read and display the server's reply, and enable the Delete button if the transaction was successful (note that after a successful find transaction, the person's name and phone number should appear on the screen). If the person's name is missing, send nothing to the server but display an error message.
When Delete is selected, verify that the person's name is present. If it is, send the person's name to the server as part of a delete transaction, read and display the server's reply, and disable the Delete button. If the person's name is missing, send nothing to the server but display an error message.
18 years ago
I have tried it few differnt ways and nothing compiles this way,
18 years ago
There are two spots under were I have two put try catch statements with exception errors in I am not sure were or how to put them to accomplish whats listed below and help would be greatly appreciated. I had it working i started inserting another try catch statement under the add butoon it not working either.
The exception error part is what i am missing from below I have tried with try catch statments
requirments
Part number (a TextField). For entering the part number. This value will be used as the key for storing and retrieving a specific Part object from the Map collection. The only edit that must be directly performed by the application is to verify that the part number does not exceed that of the HTML "maxPart" parameter (see below). Other editing (testing for a value less than zero) should be performed by methods of the Part class which may throw an Exception object.
Description (a TextField). For entering and displaying the part description. It must never be null or blank when attempting to add a Part object to the Map collection. The editing should be performed by methods of the Part class which may throw an Exception object.
Quantity (a TextField). For entering and displaying the part quantity. It must never be null, blank, or less than zero when attempting to add a Part object to the Map collection. The editing should be performed by methods of the Part class which may throw an Exception object.
Add (a Button). When clicked, test the part number to determine if it is less than the maximum part number specified by the HTML "maxPart" parameter value (see processing notes below). If so, attempt to construct a Part object from the values in the text fields. If a construction error occurs, display an error message in the message area. If construction succeeds and if the part number is NOT already in the key set, add the Part object to the Map. Display the result in the message area ("Add successful", "Duplicate object", etc.).

18 years ago
I can not get the find button to return the data from the hash map. I have tried everything I can think of with using the key, get, from the hashmap.
If more code is need let me know.
18 years ago
I got it to show a frame now but when I click on about under the menu it shows a frame but I will no draw an oval or anything from the Graphics package. I added about section under the action listner class listed on large secion of code above. But once with about window runs you can see in blow up in the command promp.
18 years ago
I have a help menu bar and it has about section and when that is called I want to open another frame and have my name and a logo of sorts. I am having hard time even having it open the frame window once about is selected. Below I have commented out thinking I am on the right track. I am not sure I keep looking at suns java.awt packet and I can't find anything that will help. Any ideas would greatly appreciated
18 years ago
were are u saying thats suppose to go?
19 years ago
I want to read in the employee name that is enter from the user and store it to a vector. I have tired it and its under the employee case. All the examples are with data that is already put in to a vector.
19 years ago
were are u saying thats suppose to go?
19 years ago
I have this is on my employee class and my customer class.
public String toString() {
String result = fullname() + ", " + getPrate() ;
return result;
and it gives me this error 'void' type not allowed here at line 161
19 years ago
Its giveing me these errors "Class Employee should be declared abstract; it does not define method fullname() in class Employee at line 128"
andClass Customer should be declared abstract; it does not define method fullname() in class Customer at line 161. There not suppose to be abstrac just the Person class is.
19 years ago