Principle of representing (non-numerical) information:
Example: representing the "gender" information
Example: representing the "marital status" information
The importance of the context used to decipher a code
What is the sex and marital status of each person ???
Without the context, we cannot decode the code value 0 (or 1) !!!
The importance of the context used to decipher a code
What is the sex and marital status of each person ???
With the correct context, we can decode the code value 0 (or 1) !!!
(Don't use the word "You" as a personal pronounce....)
(Try print the variables out in a Java program !!!)
Encoding method used by some commonly used data types:
|
We will learned more about the different encoding method later in the course
Possible solution:
public class Person { String name; // Variable reserved for gender info int gender; // Variable reserved for mari stat info int maritalStatus; ... } |