Advertisement
mokahato

Candidate

Mar 23rd, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. /**
  2.  * COSC 1020 - Project 6
  3.  * Explain briefly the functionality of the class.
  4.  * @author Chris Nadolny Conor Ward
  5.  * jain
  6.  * TA-BOT:MAILTO chris.nadolny@marquette.edu conor.ward@marquette.edu
  7.  */
  8. public class Candidate extends Citizen implements OrderedSet{
  9.     private char party;
  10.     private int supporters;
  11.    
  12.     public char getParty(){
  13.         return party;
  14.     }
  15.     public void setParty(char party) {
  16.         this.party = party;
  17.     }
  18.     public int getSupporters(){
  19.         return supporters;
  20.     }
  21.     public void increaseSupporterBy(int count) {
  22.         supporters += count;
  23.     }
  24.     public Candidate(String name, char party) {
  25.         super(name);
  26.         this.party = party;
  27.         supporters = 0;
  28.     }
  29.     public OrderedSet[] sort(OrderedSet[] s, int criterion) {
  30.         OrderedSet temp;
  31.         if (s==null) return null;
  32.         if (criterion != 0) return s;
  33.         else {
  34.             for (int i = 0; i < s.length-1; i++) {
  35.                 for (int j = i+1; j < s.length; j++) {
  36.                     if (((Citizen) s[i]).getName().compareTo(((Citizen) s[j]).getName())>0) {
  37.                         temp = s[i];
  38.                         s[i] = s[j];
  39.                         s[j] = temp;
  40.                     }
  41.                 }
  42.             }
  43.             return s;
  44.         }   }
  45.     public static void main(String[] args) {
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement