MSC Halifax Community College Java Programming & JSON Processing Homework The objective of Assignment 4 is to integrate networking capabilities into the courseregistration app that you developed for assignment 3. The app will communicate with a servervia HTTP connection. You will also practice AsyncTask, JSON processing, and using an externallibrary. CS364 Assignment 4
The objective of Assignment 4 is to integrate networking capabilities into the course
registration app that you developed for assignment 3. The app will communicate with a server
via HTTP connection. You will also practice AsyncTask, JSON processing, and using an external
library.
For more information about HTTP methods, please check
https://www.restapitutorial.com/lessons/httpmethods.html
Your app will fetch data from a server or post data onto a server as an HTTP client by sending
HTTP (GET) request or HTTP (POST) request. The task are as below.
1. Fetch data: fetch detailed information of all courses from the server.
Instead of hard coding all the courses in your code, you will fetch the courses from a server:
http://35.203.95.76:8809/course-details/
(using HTTP GET method). If the fetch is
successful, it will receive details of the courses in the following format:
[
{
“coursename”: “Introduction to Coding”,
“term”: “2nd term”,
“courseDescription”: “NAN”,
“courseNumber”: “CS128”,
“condition”: “”,
“prerequitiesOne”: “”,
“prerequitiesTwo”: “”,
“seletionStatus”: false,
“imageUrl”: “https://XXXXXXX.png”
},
….
{
“coursename”: “Theory of Computing”,
“term”: “1st term”,
“courseDescription”: “NAN”,
“courseNumber”: “CS356”,
“condition”: “2”,
“prerequitiesOne”: “CS255”,
“prerequitiesTwo”: “CS277”,
“seletionStatus”: false,
“imageUrl”: “https://XXXXXXX.png”
},
…
]
The app then parses the data, initiates the storage, and displays the list of courses. Note that
we assume there are at most two prerequisites for each course.
Note: the interpretation for
“Condition” = “1” indicates OR condition for the two prerequisites;
“Condition” = “2” indicates AND condition for the two prerequisites;
Probably your previous APP can only deal with one prerequisite. If this is the case, for the few
courses that have different prerequisites than what you had before, you can ignore the extra
prerequisites and set the prerequisite to what you had before.
Add an image to each course in the recyclerview (that shows the list of all courses). You may
use the image with the link indicated by “imageUrl” provided in the fetched data (just some
random images) or use some images from the network that are more relevant (for example, the
textbook images).
To do this, you can use Picasso Library. More information can be found
at: https://square.github.io/picasso/.
2. Add code to upload the registered courses onto the server
You will use the HTTP POST method for this task. The server is at:
http://35.203.95.76:8809/register/
The server can accept a JSON string with the following keys. Set RequestProperty for the HTTP
connection as below.
JSONObject obj = new JSONObject();
obj.put(“student_id”,”yourSID”);
obj.put(“name”,”yourName”);
obj.put(“email”,”yourEmail: x20xxxxx@stfx.ca”);
obj.put(“course”,”Data Science, Data Communication and Networking”);
//course names separated by comma
connection.setRequestMethod(“POST”);
connection.setConnectTimeout(2000);
connection.setDoInput(true);
connection.setRequestProperty(“Content-Type”, “application/json”);
connection.setRequestProperty(“Accept”, “application/json”);
To check if the registration info is successfully uploaded to the server, get the response code
from the server. In your report, show the screenshot of the response code that was displayed.
Unfortunately, you cannot request your registered courses from the server. Thus, you will still
use local persistent storage for the registered course.
Purchase answer to see full
attachment
Consider the following information, and answer the question below. China and England are international trade…
The CPA is involved in many aspects of accounting and business. Let's discuss some other…
For your initial post, share your earliest memory of a laser. Compare and contrast your…
2. The Ajax Co. just decided to save $1,500 a month for the next five…
How to make an insertion sort to sort an array of c strings using the…
Assume the following Keynesian income-expenditure two-sector model: AD = Cp + Ip Cp = Co…