Skip to main content
added 6 characters in body
Source Link
Andreas
  • 147
  • 5

OpportunistJAVA: Opportunist


package Humans;

/**
 * Always follows the group who was strongest the last turn.
 */
public class Opportunist extends Human{

    @Override
    public String takeSides(String history) throws Exception {
        int participants = history.length();
        String str = history.replace("0", "");
        int good = str.length();
        return (good > participants/2 ? "good" : "evil");
    }

    
}

Opportunist


package Humans;

/**
 * Always follows the group who was strongest the last turn.
 */
public class Opportunist extends Human{

    @Override
    public String takeSides(String history) throws Exception {
        int participants = history.length();
        String str = history.replace("0", "");
        int good = str.length();
        return (good > participants/2 ? "good" : "evil");
    }

    
}

JAVA: Opportunist


package Humans;

/**
 * Always follows the group who was strongest the last turn.
 */
public class Opportunist extends Human{

    @Override
    public String takeSides(String history) throws Exception {
        int participants = history.length();
        String str = history.replace("0", "");
        int good = str.length();
        return (good > participants/2 ? "good" : "evil");
    }

    
}
Source Link
Andreas
  • 147
  • 5

Opportunist


package Humans;

/**
 * Always follows the group who was strongest the last turn.
 */
public class Opportunist extends Human{

    @Override
    public String takeSides(String history) throws Exception {
        int participants = history.length();
        String str = history.replace("0", "");
        int good = str.length();
        return (good > participants/2 ? "good" : "evil");
    }

    
}