Lines 102 to 124 is my inputSystemTask() method. It asks users to input a month, day, hour, minute, and a message. It then passes each variable to another class, UserInput(), to check for correct input.
Lines 94 to 100 is my toString() method that prints a message using the month, day, hour, minute, and message variables.
On lines 128 to 130 of my main method I am attempting to print the new user input variables using my toString() method. It will print my default values for my variables, but not my new user input variables.
Where am I going wrong?
Scott M Summers wrote:Right, I am sending values to my UserInput class, to check if it is within the correct parameters. I'm using to set the value from the variable in UserInput to the value for my variable in SystemTask.
But you already know that the value of the month variable is correct. It's "Jan", because you already assigned that value to it in the constructor. So what's the point of sending it to the UserInput class? Shouldn't you be checking the value which the user typed in instead?
Especially since you don't seem to do anything after that, based on whether it's acceptable or not. Especially, you don't assign any new value to the month variable, and that results in the problem you already complained about.
I don't want to send my default value to my UserInput class, nor am I. I send the user input from inputSystemTask() to the UserInput class.
UserInput will check to see if the user input is within the parameters and returns a variable. I need the returned variable from UserInput to be assigned as my new month, new day, new hour, and new message. This way I can print the new variables that the user input using my toString() method.
Code for UserInput:
Scott M Summers wrote:"Jan" is the default value for month.
I don't want to send my default value to my UserInput class, nor am I.
On the contrary, that's exactly what this line of code does:
It assigns the value of variable "month", which until you change it (which you never do) contains the default value of "Jan", to something inside the UserInput class.
I need the returned variable from UserInput to be assigned as my new month, new day, new hour, and new message.
Well then, why don't you do that? You need to assign something from the UserInput class to the "month" variable, and you don't have any code which does it.