• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to access private variables in Material from DataMgt in this code. Void output returning errors  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public void getquantity() {
this.quantity = quantity;

}


get method should return the value not set the value. May be problem is here. I have not checked deeply.
 
Ranch Foreman
Posts: 3074
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are getting errors then you should post them in full, along with highlighting the line in your code that has the issue.
 
Marshal
Posts: 56610
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seke mutema wrote:
Why are you importing Swing classes? You appear not to be using them here. You should keep logic and display apart, so keep all Swing code in separate classes.
Beware of that List in the constructor. You now have two references to the same object, which means that any changes outwith your class will be reflected here and vice versa. The simplest way to avoid that is like this:-
this.materials = new ArrayList(materials);
If you look up that constructor, you will see you are copying the List so you now have two separate Lists which can change independently of each other.
Why have you got a no‑arguments constructor? That permits people to create a Job instance without supplying any information. Is that what you really want?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!