Steve
Brad Edwards wrote:These are the instructions I was given by my instructor....
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Brad Edwards wrote:These are the instructions I was given by my instructor....
Public methods named set... to assign values to the properties by using a single argument passed to each method
Steve
Public methods named set... to assign values to the properties by using a single argument passed to each method
Steve
Brad Edwards wrote:Bottom line is... I have no clue what to put in it to make it right....
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Brad Edwards wrote:ok, I have been working on this problem for a month now to get it right. I have watched tons of youtube tutorials as well as countless google searches. I have tried many different ways to get the program to work, all of which has been a complete failure. Ive gotten the program to compile correctly however when I tested it to make sure that the variables were getting Set into the correct class file, I was getting a null value. Here is what I have so far
it is giving me these errors...
G:\School\ITEC2710 Java Application Programming\Labs\Lab4\Lab4.java:16: error: cannot find symbol
names.setFirstName(customerFirstName) = input.next();
^
symbol: variable customerFirstName
location: class Lab4
G:\School\ITEC2710 Java Application Programming\Labs\Lab4\Lab4.java:20: error: cannot find symbol
names.setLastName(customerLastName) = input.next();
^
symbol: variable customerLastName
location: class Lab4
G:\School\ITEC2710 Java Application Programming\Labs\Lab4\Lab4.java:27: error: cannot find symbol
setItemNum(itemNumber) = input.nextInt();
^
symbol: variable itemNumber
location: class Lab4
G:\School\ITEC2710 Java Application Programming\Labs\Lab4\Lab4.java:31: error: cannot find symbol
setCost(itemCost) = input.nextFloat();
^
symbol: variable itemCost
location: class Lab4
G:\School\ITEC2710 Java Application Programming\Labs\Lab4\Lab4.java:35: error: cannot find symbol
setMfgName(manufacturerName) = input.next();
^
symbol: variable manufacturerName
location: class Lab4
5 errorsTool completed with exit code 1
Brad Edwards wrote:yes, I have changed the program since then to try and correct the problem I was having with the variables not being Set into the Name and Item Class files...
Brad Edwards wrote:ok, I have been working on this problem for a month now to get it right...
I have watched tons of youtube tutorials
as well as countless google searches.
I have tried many different ways to get the program to work, all of which has been a complete failure. Ive gotten the program to compile correctly however when I tested it to make sure that the variables were getting Set into the correct class file, I was getting a null value. Here is what I have so far
...
it is giving me these errors...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Brad Edwards wrote:customerFirstName is in the Name class...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Brad Edwards wrote:Henry the old program is the one that complied however it did not Set the variables correctly to the different classes. I have changed the program since then and these are the issues I am having with it now.
Henry Wong wrote:
As for the compiler error, basically the compiler is complaining that the expression is not valid.
There are many reasons for this, but the reason that the compiler is complaining about is that "customerFirstName" is not a variable that is in scope.
Brad Edwards wrote:I thought by putting the names.setFirstName would show that the program needs to look for the argument in the Name class... so by putting names.setFirstName(names.customerFirstName) would solve the problem?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Brad Edwards wrote:I thought by putting the names.setFirstName would show that the program needs to look for the argument in the Name class... so by putting names.setFirstName(names.customerFirstName) would solve the problem?
It might (if the variable isn't private), but basically, it's bad practise.
Think about it: what are you trying to do? You're trying to access the customerFirstName of an object that doesn't yet exist.
My suggestion (this will be becoming boring for those who have seen it before, but it's the same as I give to all newbies):
1. STOP CODING.
2. Turn your computer OFF.
3. Get out a pencil and paper and write down in English (or your native language) the steps you need to do to solve your problem.
4. When (and only when) you know and understand every step...
Turn your computer back on and either
(a) Start from scratch; or
(b) Re-factor your existing program to do what it is supposed to do.
Until you understand the problem, programming will be a very hard road.
Winston
Brad Edwards wrote:It works great and I'm now off suicide watch...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Don't get me started about those stupid light bulbs. |