Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • 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
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

what is the meaning of Order class in Customer Class

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have following java programme as well,



but in this code I can,t understand why Line 1 and Line 2 written here (I have commented Line 1 and 2 above code)? I need some explain about above codes segments
 
Marshal
Posts: 25927
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Customer class is meant to describe a customer, i.e. an instance of Customer contains information which is relevant to a customer. Remember, computer language code is written for the purpose of doing something useful, at least in real life it is.

In this example a Customer has a code, which is probably meant to be a customer number. And a Customer has a name, which is a String value. And finally it has an Order, which in real life... well, you know what a customer does when they send in an order. In this case a Customer can only have one order, which isn't all that real-lifey but this exercise is meant to be not too complicated.

And an Order has only an orderId, which is a String value. Of course in real life an order would have more information than that, but again this is meant to be a simple exercise.

A Customer gets its code and its name when it's created by the constructor (line 19), and in this example the code is 1001 and the name is John. And then it can be assigned an Order via its setOrder method (line 21).

Does that help?
 
Onion rings are vegetable donuts. Taste this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic