@pieromqwerty/

APCSA Lab 3

Java

No description

fork
loading
Files
  • Main.java
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import java.util.Scanner; // import the Scanner class
import java.util.*; 

public class Main {
  public static void print(String str) {
        System.out.println(str);
    }

  public static String promptString(String str) {
	  Scanner input = new Scanner(System.in);
	  System.out.println(str);
	  String response = input.nextLine();
	  return response;
  }

  public static Vector tweetParseFirst(String tweet, String section) {
	  int start = tweet.indexOf(section);
	  int end = tweet.indexOf("; ");
	  int valLength = section.length() + 1;
	  String zero = tweet.substring(start + valLength,end);
	  String one;
	  try {
		  one = tweet.substring(end + 2);
		  print("yeeeeeeeet)");
		  }
		  catch (Exception e) {
			  one = tweet.substring(end);
			  print("it fucked up");
		  }
	  Vector<String> response = new Vector<String>();
	  response.add(zero);
	  response.add(one);
	  //String response = zero + "+-+-split-+-+" + one;
	  return response;

  }

  public static Vector tweetParseFull(String tweetRaw) {
	  Vector<String> response = new Vector<String>();
	  Vector<String> otherFunc = new Vector<String>();
	  otherFunc = tweetParseFirst(tweetRaw, "#typ");
	  response.add(otherFunc.get(0));
	  otherFunc = tweetParseFirst(tweetRaw, "#det");
	  response.add(otherFunc.get(0));
	  otherFunc = tweetParseFirst(tweetRaw, "#loc");
	  response.add(otherFunc.get(0));
	  otherFunc = tweetParseFirst(tweetRaw, "#lat");
	  response.add(otherFunc.get(0));
	  otherFunc = tweetParseFirst(tweetRaw, "#lng");
	  response.add(otherFunc.get(0));
	  System.out.println(response);
	  return response;
  }

  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
	//String tweetRaw = prompt("Enter raw tweet data: ")
	String tweetRaw = "#typ offer; #det free essential supplies 4 evals pets.; #loc 2323 53rd st. boulder; #lat 40.022; #lng -105.226";
	System.out.println(tweetParseFull(tweetRaw));
	//System.out.println(tweetParseFirst(tweetRaw, "#typ"));
  }
}