This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Calculator { | |
public static double calculate (double a, String op, double b) throws Exception { | |
switch (op) { | |
case "plus": | |
return a+b; | |
case "minus": | |
return a-b; | |
case "div": | |
return a/b; | |
case "times": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person { | |
private String name; | |
private String email; | |
private int age; | |
public Person(String name, String email, int age) { | |
this.name = name; | |
this.email = email; | |
this.age = age; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mLiveData.observe(this, Observer { | |
when (it) { | |
0 -> zero() | |
1 -> one() | |
null -> mLiveData.postValue(0) //Initialise | |
else -> many() | |
} | |
}) |