You might not have forty of them, but those six braces in a row suggest you are making heavy weather of the nested ifs. You will sometimes need nested ifs, but when you see that sort of thing, start thinking there should be an easier way to do it.Civile, si ergo, fortibus es in ero…
Start with the Java Tutorials section, and this smaller section. You declare the package by writing its name after the keyword package. Very first line of the class, before the imports. What you write, that is the package your class goes into.Jessica Stensrud wrote: . . . How do I make sure my stuff is all in the same package? . . .
SUMMARY:
So, putting all that together, and assuming CashRegister and its launcher are in the same package, we get:
CashRegisterLauncher.java:
I would suggest that the keyword static should be the exception. Things should default to being non‑static (i.e. they belong to the instance). Things static belong to the class. If you have your fields not static, they can have different values in each object, but they have no existence until an object is created. So you should move everything out of the main method. A main method should have one statement. You can see an example here. As you can see, that creates an object and calls a method which starts the application off.
Joanne
When you do things right, people won't be sure you've done anything at all.
please buy my thing and then I'll have more money:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|