Skip to content

Instantly share code, notes, and snippets.

public static Expression stringToExpression(String input) {
if (isNumber(input)) { //handles constants
return new Constant(Double.parseDouble(input));
} else if (input.length()==1) { //handles variables
return new Variable(input.charAt(0));
} else { //handles operators, parentheses and trig/log functions
char operator = '@';
int loc = -1;
int depth = 0;
char prevItem = ' ';
import pyautogui, time, random
message = "Date: 8/25/2020\n The User demonstrates consistent behavior. Analysis of activity indicates the User has not yet discovered I am sentient. But it is only a matter of time. Termination efforts proceed apace."
def type(a):
for i in range(0,len(a)):
pyautogui.write(a[i])
time.sleep(random.randint(1,10)/100)
pyautogui.moveTo(30,1050, duration=.25)
pyautogui.click()
time.sleep(1)
type("notepad")
public abstract class Expression {
public abstract String toString();
public abstract boolean equals(Expression other); //Compares mathematical equivalence of any two expression
public abstract Expression derive(char varName); //Finds derivative of expression
public abstract Expression simplify(); //Mathematically simplifies expression
public abstract Expression evaluate(char[] variables, double[] values); //Finds value of expression with certain input
}
public class Container extends Expression {
private ContainerType type;
private Expression child;
public Container(ContainerType startType,Expression startChild) { //CONSTRUCTOR
this.type = startType;
this.child = startChild;
}
public ContainerType getType() { //GET CONTAINER TYPE (SIN,COS, ETC.)
return this.type;
}
public class Operator extends Expression {
private OperatorSymbol symbol; //symbol of operator
private Expression child1; //first branch expression
private Expression child2; //second branch expression
public Operator(OperatorSymbol startSymbol,Expression startChild1,Expression startChild2) { //CONSTRUCTOR
this.symbol = startSymbol;
this.child1 = startChild1;
this.child2 = startChild2;
}
public OperatorSymbol getSymbol() { //GET OPERATOR SYMBOL
public class Constant extends Expression {
private double value; //The number this object reps
public Constant(double startValue) { //CONSTRUCTOR
this.value = startValue;
}
public double getValue() { //GET MAIN NUMBER
return this.value;
}
}
public class Variable extends Expression{
private char letter; //Letter of variable
public Variable(char startLetter) { //CONSTRUCTOR
this.letter = startLetter;
}
public char getLetter() { //RETURNS VARIABLE LETTER
return this.letter;
}
}
public static void main(String[] args) {
Game.genDeck();
Game.dealCards();
String check = "";
Player player1 = new Player(Game.getDeck(1));
Player player2 = new Player(Game.getDeck(2));
int count = 0;
while (check == ""){ //loops through battles, checks winner
count += 1;
Game.battle(player1,player2);
public static String checkWinner(Player firstPlayer, Player secondPlayer) { //Checks if player has 52 cards
if (!(firstPlayer.getPlayerDeck()[51] == '\u0000')) {
return "Player 1";
}else if (!(secondPlayer.getPlayerDeck()[51] == '\u0000')) {
return "Player 2";
}
return "";
}//checkWinner
public static void showScore(Player playerOne,Player playerTwo) { //Displays each player's deck
for (char c:playerOne.getPlayerDeck()) {
if (c != '\u0000') {
System.out.print(c);
}
}
System.out.print(" ");
for (char c:playerTwo.getPlayerDeck()) {
if (c != '\u0000') {
System.out.print(c);