Here is my constructor that the toString method pulls from:
public Actor(String sName, int nStrength, int nSpeed, int nHealthPoints){
this.sName = sName;
this.nStrength = nStrength;...
Type: Posts; User: tyneframe
Here is my constructor that the toString method pulls from:
public Actor(String sName, int nStrength, int nSpeed, int nHealthPoints){
this.sName = sName;
this.nStrength = nStrength;...
Alright, thanks again. I should be able to figure it out at this point.
--- Update ---
I solved it! Who knew a ; could cause so much chaos, haha. I'll definitely remember all these...
It's almost there. The NPE error at line 108 is gone. I can enter as much info as I want. Now I've just got to deal with the NPE error at line 112 where the user chooses to view the data that has...
So, if I move my employeeData[numEmployee] = new Employee(); object down into the loop, that should create a new object each time the user chooses 1.
Something like this:
...
Okay this is slowly starting to make sense, but how do I fix my NPE problem without putting data into all 100 slots? 100 is just the max number of slots the user has to work with, but they don't have...
Wow, I'm having a hard time accessing the forums right now. Anyway...
Okay, tried that and I got 'Employee@3c939d40' for the first entry and then I got null values. I'm assuming 99 null values...
Ah sorry, misunderstood what you wrote. That I know how to do.
so, to call the elements in the array I should write:
System.out.println(employeeData[numEmployee]); ?
But all I get is null as a...
Sorry, not sure I understand what you mean. How do I add a call to the println?
If I'm not mistaken, I'm putting objects into my array with line 108...am I not? But if that's the case, I am getting the NPE because the entry is not being put into the array properly. Is that what...
That's my problem. I don't know what is null at line 108. Nothing is null the first time I run through, so I don't understand why something is null the second time. Is there a way to find out what is...
I'm having some issues with entering data into my array. The first run through the loop has no issues...that I can see, but once I have entered the first batch of information I start getting Null...
Here's the updated code, and the error message is:
"Exception in thread "main" java.lang.NullPointerException at Employee.main(Employee.java:109)"
public static void main(String[] args) {
...
Hey, thanks. That did the trick... but also brought up a new problem it seems. After I select 1 for the first time and enter some information it loops me back to the menu and asks me to select again....
Nearing the end of this assignment and am having a little trouble figuring out a way to get my loop to return to the proper place each time it repeats. Here's the section of code I'm working on:
...
Thank you so much for the help! It works perfectly now. Can't believe I forgot the == thing.
Thanks again.
Hm, I'm still not sure what I'm doing wrong. I've tried entering the boolean and setting the result based on the numberEntered just like you said, but I keep getting an error that says "cannot make a...
Sorry, my mistake. It is supposed to keep repeating until the user enters 13. How do I go about setting a value to finished?
At least I think the solution to my problem will involve a loop. I'm new to java, so I'm sorry if I'm on the wrong board.
Basically, my code asks the user to enter a number from 1 - 12 and it then...
Thank you very much for the help and links. I'll check them out.
Repeating the main method seemed like the simplest thing to re-run the code and allow the user to re-enter a number, if their first try was invalid. I am new to this...only a couple of weeks into the...
Just starting out in Java and need a little help.
I'm writing a simple code where the user is asked to enter a 5 digit number, otherwise they get a 'please try again' message. I've figured out most...