Sunday, 2 June 2013

2 identical classes in Java

Hi!
I have a small design problem in my current project. I have a class that holds the information about the time a Customer was in a Shop.
public class Customer {
    private String enterTime;
    private String leaveTime;

    public void enterTimeToInt {
        Integer.parseString(enterTime);
    }

    public void leaveTimeToInt {
        Integer.parseString(leaveTime);
    }
}
Now, in my program, i came across a situation where i had to make sure if there was any customer in the shop at a given time. Now, what i did was that i made another instance of the Customer class, which represented the given time and then checked if it matches any "real" Customer. But the problem is though, that i made a customer object representing time in a more abstract sense, not a customer.
What should i do in this case? I need exactly the same methods and variables as the Customer class has, but i don't think it is a good design choice to just make a Customer class that represents random time, not a specific customer's time.
Thank you very much!

No comments:

Post a Comment