Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Name{// Class Header - Names the class
- //Instance Variables - Data associated with each name
- private String name, gender;
- private int frequency;
- //Parameterized Constructor - Creates a name with given information
- public Name(String n, String g, int f){
- name = n;
- gender = g;
- frequency = f;
- }
- //Accessor Methods - Allows us to see values of private instance variables outside of class
- public String getName(){
- return name;
- }
- public String getGender(){
- return gender;
- }
- public int getFrequency(){
- return frequency;
- }
- //toString Method - Returns a textual representation of each Name object
- public String toString(){
- return name + ", " + gender + ", " + frequency;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement