• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

simple customer management system questions  RSS feed

 
Ranch Hand
Posts: 423
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
 
Sheriff
Posts: 12748
210
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: 423
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?
 
Sheriff
Posts: 5458
147
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?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!