Skip to content

Instantly share code, notes, and snippets.

@tangmae
Created October 9, 2012 05:44
Show Gist options
  • Save tangmae/3856844 to your computer and use it in GitHub Desktop.
Save tangmae/3856844 to your computer and use it in GitHub Desktop.
[Homework#1]Mobile
class Mobile()
{
}
class monitor{
String output;
int mode;
//mode 1 => home || mode 2 => keynum || mode 3 => call
public monitor()
{
System.out.println("================");
System.out.println("== ==");
System.out.println("== ==");
System.out.println("== ==");
System.out.println("== ==");
System.out.println("== ==");
System.out.println("================");
mode = 1;
}
public void isShowMoniter(String a)
{
if(mode==1)
{
mode =2;
isShowMoniter(a);
}
if(mode==2)
{
while(!a.equals("turnoff"))
{
if(!a.equals("back")&&!a.equals("call")&&!a.equals("select"))
{
output = output+a;
System.out.println(a);
}
if(a.equals("back"));
{
if(output!=null)
{
temp = output.subString(0,output.lenght-1);
output = temp;
System.out.println(a);
}
}
if(a.equals("call"))
{
mode=3
isShowMoniter(call);
}
if(a.equals("select")
{
System.out.println("Remember");
output = output;
}
}
if(a.equals("turnoff"))
{
mode =1;
isShowMoniter();
}
}
if(mode==3)
{
while(!a.equals("turnoff"))
{
System.out.println(".");
sleep(10);
System.out.println("..");
sleep(10);
System.out.println("...");
}
if(a.equals("turnoff"))
{
mode = 1;
isShowMoniter();
}
}
}
}
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 boolean isReceiveInput(String a)
{
int result = isFindAllKey(a);
if(result>0)
{
if(result<10)
{
isShowMoniter(numKey[result]);
}
else if(10=<result<14)
{
isShowMoniter(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 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