Skip to content

Instantly share code, notes, and snippets.

@tangmae
Created October 9, 2012 07:26
Show Gist options
  • Save tangmae/3857169 to your computer and use it in GitHub Desktop.
Save tangmae/3857169 to your computer and use it in GitHub Desktop.
Homework#1
class Moblie{
}
//Global
static void int mode = 1;
static void int timecalling = 0;
public static class Monitor{
String output;
public monitor(){
output = null
}
public void isShowMoniter(String a){
if(mode==2)
{
output = output+a;
System.out.println(output);
}
if(mode==3)
{
output = a;
while(!a.equals("turnoff"))
{
System.out.println("Call "+output)
System.out.println(".");
sleep(50);
System.out.println("..");
sleep(50);
System.out.println("...");
}
}
if(mode==4)
{
while(!a.equals("call"))
{
System.out.println(number[lastline]+" is call in")
}
if(a.equals("call"))
{
mode=3;
isShowMoniter();
}
}
}
}
public static class keyboard{
String[] numKey;
String[] controllKey;
public keyboard(){
numKey = {"1","2","3","4","5","6","7","8","9","0"};
controllKey ={"back","call","select","turnoff","VolumnUP","VolumnDOWN"};
}
public void isKBReceiveInput(String a){
int result = isFindAllKey(a);
if(result>0)
{
if(result<10)
{
isGetInput(numKey[result]);
}
else if(10=<result<14)
{
isGetInput(controllKey[result-10]);
}
else
{
if(result==14)
{
isTurnUp();
}
else
{
isTurnDown();
}
}
}
}
public int isFindAllKey(String a){
for(int i=0;i<numKey.lenght;i++)
{
if(numKey[i].equals(a))
{
return i;
}
}
for(int j=0;j<controllKey.lenght;ji++)
{
if(controllKey[i].equals(a))
{
return 10+i;
}
}
return -1;
}
}
class MobileSys{
ArrayList number;
String[] member;
int mode;
int lastline;
int list;
String teltemp;
public MobileSys(){
number = new ArrayList();
member = new String[10];
mode =1;
list = 0; // no member mem in memory
}
public void isHome(String a){
if(a.equals("0")||a.equals("1")||a.equals("2")||a.equals("3")||a.equals("4")||a.equals("5")||a.equals("6")||a.equals("7")||a.equals("8")||a.equals("9"))
{
mode = 2;
isGetInput(a);
}
}
public void isAtKeyNum(String a){
while(!a.equals("turnoff"))
{
if(a.equals("0")||a.equals("1")||a.equals("2")||a.equals("3")||a.equals("4")||a.equals("5")||a.equals("6")||a.equals("7")||a.equals("8")||a.equals("9")||a.equals("back"))
{
isShowMoniter(a);
}
if(a.equals("select"))
{
String temp = monitor.output;
member[list] = temp;
}
if(a.equals("call"))
{
mode =3;
teltemp = monitor.output;
isGetInput(monitor.output);
}
}
else if(a.equals("turnoff"))
{
mode = 1;
}
}
public void isCalling(String a) {
while(!a.equals("turnoff"))
{
number.add(teltemp);
lastline++;
currentNumber = number.get(lastline);
isShowMoniter(currentNumber);
isCalling(a);
}
if(a.equals("turnoff"))
{
number.remove(lastline);
if(number.isEmpty())
{
lastline = 0;
mode = 1;
}
else
{
lastline = lastline - 1;
mode = 3;
isCalling(null);
}
}
}
public void isOutCall(String a,String tel){
if(!a.equals("call"))
{
if(timecalling < 10)
{
isShowMoniter(tel);
timecalling++;
}
else
{
timecalling = 0;
mode = 1;
}
}
else
{
mode = 3;
isCalling(a);
teltemp = tel;
}
}
public void isOverlap(String a,int tel){
if(!a.equals("call"))
{
if(time < 10)
{
isShowMoniter(tel);
timecalling++;
}
else
{
timecalling = 0;
mode = 3;
}
}
else
{
teltemp = tel;
mode = 3;
isGetInput(null);
}
}
//mode 1 => home || mode 2 => keynum || mode 3 => call || mode 4 = out call || mode 5 = line overlape
public String isGetInput(String a,int tel){
if(mode == 1)
{
isHome(a);
}
else if(mode == 2)
{
isAtKeyNum(a);
}
else if(mode == 3)
{
isCalling(a);
}
else if(mode == 4)
{
isOutCall(a,tel);
}
else if(mode == 5)
{
isOverlap(a,tel);
}
}
}
public static class Speaker{
int Volumn; // 5 level
boolean mute;
public Speaker(){
Volumn = 4;
mute = false;
}
public void isTurnUp(){
if(Volumn < 5)
{
Volumn = Volumn + 1;
}
}
public void isTurnDown(){
if(Volumn > 0)
{
Volumn = Volumn-1
}
}
public void isSetMute(){
mute = !mute;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment