// Welcome back to CS01b! Please share webcams
// end of today: turn in Project update part 2
// end of the weekend: (by Monday) zip up all project files into a single file on your VM
// link to this page:
// https://pads.ktbyte.com/p/r.f72986711314d90814de8f3cab9b163a
/*
Syllabus page: https://content.ktbyte.com/cs01b/19fa/
EXTRA CREDIT/ADDITIONAL TASKS TO EXPLORE
- ToDo List file reading
- User interface improvement (explore javafx classes and methods)
- experiment with "AI" of getting likelihoods of commands
TODO LIST EXTRA CREDIT
useful tools to do these (research those yourself or look at other examples!)
Scanner - read text from files
PrintWriter - write text to files
VM SHORTCUT TO VIEW CLIPBOARD
- Mac: Ctrl+Option+Shift
- PC: Ctrl+Alt+Shift
- Copying INTO VM:
1. Copy what you want from your computer
2. Open side panel
3. Paste into the side panel (from your computer)
4. Close side panel
5. Paste AGAIN in your VM
- Copying OUT OF VM:
1. Copy what you want from your VM
2. Open side panel
3. Copy AGAIN out of the side panel
4. Close it
5. Paste into your computer's programs
PRIORITIES FOR TODAY
- TodoList app basic funtions should be COMPLETELY DONE
- Web API chosen should be MOSTLY DONE and COMPLETELY UNDERSTOOD (structure of requests for your chosen site)
STATIC VARIABLES MAY BE USEFUL FOR SHARING INFO B/W CLASSES
class MyApp {
static VarType varName; creates a variable that can be accessed through the class
it's in (not an instance)
}
MyApp.varName ... any other class can access that variable through the class's
name
WEB API NOTES
some nice simple APIs from the list:
agify.io
nationalize.io
(also calculator app linked on syllabus)
AGIFY API EXAMPLE
command: guess my age with michael
command: my name is Melinda
I think your age is 28, Melinda
MATH API EXAMPLE
Command: calc 2*(7-3)
8
Command: calc 2/3
0.66666666666
http://api.mathjs.org/v4/?expr=2*(7-3)
^? shows where the query parameters/query strings begin
expr= <-- name of query param
=2*(7-3) <-- value/string for that query param
http://api.mathjs.org/v4/?expr=2%2F3
expr=
=2%2F3 <-- encoded version of 2
WEB API PROGRAM FLOW
1. Process the command - get the DETAILS needed from the command that will eventually
be provided to the site you chose
2. Form the request - using the documentation you found on your chosen site, put
together the request using Unirest; requests may have
a. start with Unirest.get(url) or Unirest.post(url)
b. often include query strings/parameters with .queryString(label,value)
c. might include headers with .header(label,value)
d. can add custom words in the URL using manual string construction OR using
.routeParam("partOfUrl", "replacement word") if your original URL had
{partOfUrl} within the String
e. POST requests sometimes have .field(label,value)
f. to include a labeled part, which has no particular value, just use "" for value
3. make the request with .asJson().getBody() or .asString().getBody()
4. use JSONObject and JSONArray functions to get the pieces you want out of the response
.getString("labelOfPartOfObject") .getJSONObject(0)
.getInt("labelOfIntWithinObject")
5. Assistant.getInstance() and .displayItem(new Response(myResults));
*/