previous | start | next

## Discovering Classes

- If you find yourself defining a number of related variables that all refer to the same concept, define a class that abstracts the concept and contains these variables as data fields.
- Suppose you are reading information about computers:
  - Model Name
  - Price
  - Score between 0 and 100
- Sample data:

  >     ACMA P600
  >     995
  >     77

  >     Alaris Nx868
  >     798
  >     57

- Sample code excerpt:

  >     if (next_score / next_price > best_score / best_price)
  >     {
  >        best_name = next_name;
  >        best_score = next_score;
  >        best_price = next_price;
  >     }

- Each of these sets of variables describes a product (a best product, and the next product read in). We need to develop a `Product` class.

previous | start | next