Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Omar Natour
- * 11/4/2016
- * Csc-220 Data Structures
- * Hw 6 Baby names
- * Create a program that orders and combines the amount of baby names from a database
- * Ojnatour0001@studnet.stcc.edu
- */
- public class BabyName implements Comparable<BabyName> {
- private String name;
- private char gender;
- private int tally;
- public BabyName(String name, char gender, int tally) {
- this.name = name;
- this.gender = gender;
- this.tally = tally;
- }
- public String getName() {
- return this.name;
- }
- public int getTally() {
- return this.tally;
- }
- public BabyName combine(BabyName c) {
- this.tally += c.tally;
- return this;
- }
- public boolean equals(BabyName o) {
- if (this.name == o.getName())
- return true;
- else if ((this.name).equals(o.getName()))
- return true;
- return false;
- }
- @Override
- public int compareTo(BabyName o) {
- return o.tally - this.tally;
- }
- public String toString() {
- return (this.name + ", " + tally);
- }
- }
Add Comment
Please, Sign In to add comment