• Post Reply Bookmark Topic Watch Topic
  • New Topic

simple customer management system questions  RSS feed

 
jon ninpoja
Ranch Hand
Posts: 291
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,

have a main class called shop and another class called customer
only have one method on the customer called createCustomer
then you enter name,age,telephone

now...should i have the createCustomer method create an object of each customer (after its accumulated the details) and store it in a list?
is that how you would tackle this? would the createCustomer method return the object to main,or the list?

i havent got much done regarding what im asking,just need to see what direction it should go...am i on the right track?

thanks for reading
 
Junilu Lacar
Sheriff
Posts: 11493
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In large systems, there would be a class or interface called CustomerRepository that is responsible for managing the collection of customers. The actual implementation should be transparent to all other classes, so they don't have to care whether the Customer objects are in a List in memory, or in a database, or in an XML file, or on little scrolls that little magic elves write on as they run around inside the computer.
 
jon ninpoja
Ranch Hand
Posts: 291
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Junilu Lacar,

im not ready to be using sql databases etc...just trying to get to grips with java language
it will only be a small program im trying to get right regarding instance variables,methods and encapsulation as well as returning values and passing arguments to methods

can you think of a worthy assignment for this?
 
Knute Snortum
Sheriff
Posts: 4279
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jon ninpoja wrote:hi guys,

have a main class called shop and another class called customer
only have one method on the customer called createCustomer
then you enter name,age,telephone

now...should i have the createCustomer method create an object of each customer (after its accumulated the details) and store it in a list?
is that how you would tackle this? would the createCustomer method return the object to main,or the list?

i havent got much done regarding what im asking,just need to see what direction it should go...am i on the right track?

thanks for reading

If you have a class call Customer (notice the uppercase "C") you would create new objects with the code:

And if you want to set name, age, and telephone, probably the best way would be:

If you were creating a List of Customers, you would probably do something like this:

You could even save a step and write:

Now, can you figure out how to write the class Customer?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!