pamela jones

Greenhorn
+ Follow
since Apr 26, 2003
Merit badge: grant badges
For More
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 pamela jones

I have written equals and hashCode methods to a class. It is suppose to detect and reject duplicate grades entered into the JPanel. When you press the View button it should show up only once but it shows up twice. I am bewildered. I have included the code I wrote. Please advise.
public boolean equals(Object o){
if (this == o){
return true;
}
if (! (o instanceof Gradeable)){
return false;
}

Gradeable other = (Gradeable) o;
return this.maxPoints == other.maxPoints
&& this.earnedPoints == other.earnedPoints
&& this.description.equals(other.description)
&& this.date.equals(other.date);
}

/**
* This method overrides the Object hashCode method.
* @return the hash code for the Object
*/
public int hashCode() {
int result = 17;

result = 37 * result + maxPoints;
result = 37 * result + earnedPoints;
result = 37 * result + description.hashCode();
result = 37 * result + date.hashCode();
return result;
}
20 years ago
How do I serialize an object to a file on my disk and then deserialize to recover the input entered into the JPanel earlier? I am having some difficulty with this. Thank you.
20 years ago
I am trying to figure out how to write serialized objects to a file and then deserialize the object. I am lost on this subject. Any coding examples I can follow? Thank you.
20 years ago
I am trying to figure out how to use the equal method and hash code to ensure that my program accepts no duplicates when entering data into the JPanel. I am also trying to figure out how to serialize a file and deserialize it. Any suggestions?
20 years ago
In a try statement in which the exception is caught how do you prevent the program from displaying error messages
This is is program whereby there exiext a button and a textfield , a figure is entered into the textfield , anytime the user presses the button th efolowing procedure is invoked.
I have written a try statement to check if the correct numbers are inputted, i want to stop the system from printing error messages if the try throws an exception pls how do i do this

public void actionPerformed(ActionEvent ae) {
int b=0;
// validate inputs
try {
Integer.parseInt(maxPoints.getText());
}
catch (NumberFormatException e){
JOptionPane.showMessageDialog(null, "the maximum points value must be a number",
"maximum points", JOptionPane.ERROR_MESSAGE);
}
20 years ago