Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * COSC 1020 - Project 6
- * This class takes a String name and uses it to create a citizen object, it then uses a sort method to order an array of Citizens.
- * @author Chris Nadolny Conor Ward
- * Instructor Jain
- * TA-BOT:MAILTO chris.nadolny@marquette.edu conor.ward@marquette.edu
- */
- public class Citizen implements OrderedSet{
- private String name;
- private Candidate candidate;
- public String getName(){
- return name;
- }
- public Citizen(String name) {
- this.name = name;
- }
- public Candidate getCandidate() {
- return candidate;
- }
- public OrderedSet[] sort(OrderedSet[] s, int criterion) {
- OrderedSet temp;
- if (s==null) return null;
- if (criterion != 0) return s;
- else {
- for (int i = 0; i < s.length-1; i++) {
- for (int j = i+1; j < s.length; j++) {
- if (((Citizen) s[i]).getName().compareTo(((Citizen) s[j]).getName())>0) {
- temp = s[i];
- s[i] = s[j];
- s[j] = temp;
- }
- }
- }
- return s;
- }
- }
- public void votesFor(Candidate candidate) {
- candidate.getCandidate();
- candidate.increaseSupporterBy(1);
- }
- public static void main(String[] args) {
- }
- }
Add Comment
Please, Sign In to add comment