*function:The problem of Mars car.
*China firmly opposes Obama-Dalai meeting
*The WAR is actually begun!Now you are the Commander of the Fleet.
*You can input command to control the Mars Car to go straight,
*turn left,turn right,and the car maybe your loyal soldier.
*The command input like this string:LL1LRR89L2,
*and at last report the location of the car to Commander.
*L means turn left,R means turn right,number0-9 means how far the car can go
*request:1).ExtremeProgramming 2).Pair Programming 3).Test Driven Development
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
public class TestMarsCar {
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out
.println(“Now,the Mars car is loarding on the Mars,input the loaction”);
System.out.println(“input x:(number)”);
String x = bf.readLine();
System.out.println(“input y:(number)”);
String y = bf.readLine();
System.out.println(“input direction:(N,W,S,E)”);
String f = bf.readLine();
System.out.println(“the car is loaded in (” + x + “,” + y + “,” + f
+ “)”);
// create Marscar object
Marscar car = new Marscar(x, y, f);
while (true) {
System.out.println(“\n***********************”
+ “\npress 1or 2 to select *” + “\n1:new command *”
+ “\n2:exit *”
+ “\n***********************\ninput number:”);
Scanner s1 = new Scanner(System.in);
int ints1 = Integer.parseInt(s1.next());
if (ints1 == 1) {
System.out.println(“input new command like (L,R,0-9):”);
Scanner s = new Scanner(System.in);
String commands = s.next();
for (int i = 0; i < commands.length(); i++) {
String command = String.valueOf(commands.charAt(i));
if (command.equals(“L”)) {
car.turnLeft(car.getF());
} else if (command.equals(“R”)) {
car.goRight(car.getF());
} else {
int n = Integer.parseInt(command);
car.goAhead(n);
}
// show the location of mars car.
System.out.println(“the new location is (” + car.getX()
+ “,” + car.getY() + “,” + car.getF() + “)”);
}
} else if (ints1 == 2) {
System.exit(0);
} else {
System.out.println(“YOu command is Wrong!”);
}
}
}
}
// -----------------------------------------
// class Marscar
class Marscar {
private String x; // x-coordinate
private String y; // Y-coordinate
private String f; // direction
public String getX() {
return x;
}
public void setX(String x) {
this.x = x;
}
public String getY() {
return y;
}
public void setY(String y) {
this.y = y;
}
public String getF() {
return f;
}
public void setF(String f) {
this.f = f;
}
// constructor
public Marscar(String x, String y, String f) {
this.x = x;
this.y = y;
this.f = f;
}
public void turnLeft(String f) {
System.out.println(“go left”);
结尾
学习html5、css、javascript这些基础知识,学习的渠道很多,就不多说了,例如,一些其他的优秀博客。但是本人觉得看书也很必要,可以节省很多时间,常见的javascript的书,例如:javascript的高级程序设计,是每位前端工程师必不可少的一本书,边看边用,了解js的一些基本知识,基本上很全面了,如果有时间可以读一些,js性能相关的书籍,以及设计者模式,在实践中都会用的到。