View difference between Paste ID: ZeUMg9bu and bWDEYJeM
SHOW: | | - or go back to the newest paste.
1
import java.util.Scanner;
2
import java.net.*;
3
import java.io.*;
4
public class Xbmcremote
5
{
6
	public static void main(String[] args) throws Exception
7
	{
8
		URL sendup = new URL("http://192.168.1.128:8080/jsonrpc?request={%22jsonrpc%22:%20%222.0%22,%20%22method%22:%20%22Input.Up%22}");
9
		URL senddown = new URL("http://192.168.1.128:8080/jsonrpc?request={%22jsonrpc%22:%20%222.0%22,%20%22method%22:%20%22Input.Down%22}");
10
		URL sendleft = new URL("http://192.168.1.128:8080/jsonrpc?request={%22jsonrpc%22:%20%222.0%22,%20%22method%22:%20%22Input.Left%22}");
11
		URL sendright = new URL("http://192.168.1.128:8080/jsonrpc?request={%22jsonrpc%22:%20%222.0%22,%20%22method%22:%20%22Input.Right%22}");
12-
		String direction = "";
12+
		int choice;
13
		URLConnection up = sendup.openConnection();
14
		URLConnection down = senddown.openConnection();
15
		URLConnection left = sendleft.openConnection();
16
		URLConnection right = sendright.openConnection();
17
		Scanner kb = new Scanner(System.in);
18-
		System.out.print("Up, Down, Left, or Right? ");
18+
		System.out.print("Choose from the following options\n"
19-
		direction = kb.nextLine();
19+
						+ "    1. Up\n"
20-
		switch(direction)
20+
						+ "    2. Down\n"
21
						+ "    3. Left\n"
22-
			case "up": up.getInputStream();
22+
						+ "    4. Right\n"
23
						+ "Enter your choice: ");
24-
			case "down": down.getInputStream();
24+
		choice = kb.nextInt();
25
		kb.nextLine();
26-
			case "left": left.getInputStream();
26+
		switch(choice)
27
		{
28-
			case "right": right.getInputStream();
28+
			case 1: up.getInputStream();
29
					break;
30
			case 2: down.getInputStream();
31
					break;
32
			case 3: left.getInputStream();
33
					break;
34
			case 4: right.getInputStream();
35
					break;
36
			default: System.out.println("EXTERMINATE!");
37
					break;
38
		}
39
	}
40
}