I have this class
class Customer{
int ID;
Time arriveTime;
Time serviceTime;
Time completeTime;
int transaction;
}
Don\'t I
The method that you are suggesting does not do a very good job of abstracting and separating variables. It allows them to be messed with by any code at will.
Part of Java is OOP, or Object Oriented Programming. If you make certain parts of the class private
and separated from the rest of the code, then it will limit access from other code, which helps your class follow the OO principle of encapsulation.
Instead, I would make a constructor that fills in the fields when appropriate, such as arrive
and id
. I would make the variables private
. Also, I would make id
a static member, because it would be incremented for every new customer.