10年专注于英语国家留学生作业代写,网课代修,网课Exam代考
程序设计代写、java留学生编程代做、代写program语言_DueEssay论文代写

程序设计代写、java留学生编程代做、代写program语言

CS代写团队10年代写经验,专注于Computer science代写,CS作业代写,C代写,C++代写,java代写,python代写,数据库代写,web代写,算法作业代写,CS assignment代写,R代写等, 涵盖北美CS代写, 英国CS代写, 加拿..

EG1hao 立即咨询

快速申请办理

称       呼 :
联系方式 :
备       注:

程序设计代写、java留学生编程代做、代写program语言

发布时间:2020-12-04 热度:

CS代写团队10年代写经验,专注于Computer science代写,CS作业代写,C代写,C++代写,java代写,python代写,数据库代写,web代写,算法作业代写,CS assignment代写,R代写等, 涵盖北美CS代写, 英国CS代写, 加拿大CS代写, 澳洲CS代写, 新西兰CS代写, 香港CS代写, math代写, 统计代写, 金融代写, business代写, economic, accounting代写


留学生编程代做、代写Java,Python/c++程序设计
Algorithm算法作业代写
Assignment代写
Project代写
Homework代写
Lab代写
C/C++ 编程代写
CS作业代写
Data Mining数据挖掘作业代写
数据结构 Data Structure作业代写
Database Mongodb postgreSql mysql Nosql SQL代写
AI作业代写 人工智能代做
Machine learning 作业代写 机器学习代写
Operating System 操作系统作业代写
EE 作业代写
编程作业代写
Java代写 Java程序代写
Linux C/C++作业代写
Python代写 Python程序代写
Web开发 网站设计 php程序代写/nodejs/css/html5/reactjs/vue等
算法实现 算法作业代写
数据分析 R代写 R语言代写 统计代写
安卓代写 移动开发
IOS代写 移动开发
Assembly 汇编作业 X86汇编 MIPS汇编代写
C#作业代写
d3.js可视化作业代写
Network 代写计算机网络
OOP代写 面向对象编程
Javafx代写 GUI编程
Linux shell代写 Bash编写
多线程代写
matlab代做 matlab编程
Scala编程 Scala代写
Math代写 数学代做
haskhell代写 haskhell编程
Racket代写 racket编程



CSE 11 Fall 2020 PA6 - Exposure Notifications
System
Due date: Wednesday, Nov 18 @ 11:59PM PST
(Thursday, Nov 19 @ 11:59PM PST w/ slip day. If you submit your assignment late, the autograder will automatically
use your slip day if you have any remaining.)
Provided Files
Simulator.java
sample.txt
You can find these two files on Canvas.
Files to Submit
ContactInfo.java
Server.java
Student.java
Goal
This programming assignment will give you an introduction to Classes in Java and a peep of Object Oriented
Programming. In this assignment, you will create three new classes from scratch with several instance variables and
methods.
Please read the entire write-up before getting started. Some of the specific implementation details won't make
sense until you understand the overall structure of all the classes and what instance variables/methods each class
contains.
Please frequently check the FAQ post on Piazza as we will address common questions there
Some Background
Since the break of COVID-19 pandemic, Google and Apple have been building an Exposure Notifications System
that can quickly notify registered users about their recent close contact with COVID-19 infected people.
Lots of thoughts have been put into this system to protect users' privacy, so this system will neither track location nor
share user's identity with any organization or other users. Instead, this system uses Bluetooth to exchange random IDs
among users. Roughly, the Exposure Notification System works as follow:
Each registered smart phone will generate a random ID that will change every few minutes so that user's
location and identity cannot be tracked.
When two phones are close enough, they will exchange their random IDs via Bluetooth.
When a user reports a positive COVID-19 case on their phone, all of their recently used random IDs will be
uploaded to a server.
Several times a day, each phone will download all the "infected" IDs from the server and compare them against
its local contact history. If one of the "infected" IDs shows up in the contact history, the phone will show the
user a notification saying they might have been in contact with COVID-19 and provide further guidance.
While the system is still in its testing phase in California, UCSD is one of the organizations in the California COVID
Notify Pilot Program which gives all UCSD students early access to this system.
Now, Chancellor Khosla wants some help from the CSE department to manage this system. You want to help but you
need to show Chancellor Khosla your capabilities by implementing a similar system using Java classes. In this
assignment, you will implement these classes.
Some General Notes
Make sure to read the autograder output after you submit to Gradescope. We cannot be lenient regarding
information that you can see by reading that output.
Match the method signatures that we provide exactly, otherwise we cannot ensure that the autograder will
function correctly.
Do not use any static variables and do not use any extra instance variables that are not specified in this writeup.
We cannot ensure that these do not get clobbered during grading. Any extra variables used should be local only
( private static final constants are fine).
Do not add any extra import s other than java.util.Random and java.util.ArrayList .
Do not specify a package for your files. This will cause them to fail to compile with the autograder.
Do not add any extra classes to your files and do not write code in files that are not specified.
Do not call helper methods except from the class where they are implemented, as we will be using our own
version of classes during grading (which will only have the instance variables and methods specified in this
writeup).
For the surveys and AI form, make sure you are filling them out and specifying your email address as the one
linked with your Gradescope account. If you fill them out after submitting, you can either resubmit to update
your score immediately or wait for us to rerun the autograder for everyone after the deadline.
Any late submission will trigger a slip day usage for this assignment. There will be no more exceptions for
"accidents," since we cannot determine if it is an actual accident.
Part 0: Validity
In the parts below, we will have multiple kinds of integer values including:
id
location
time
distance
Remember that all these values are considered valid if and only if they are non-negative (e.g. if a time is equal to
-10 , it's invalid; if a location is 0 , it is valid).
Part 1: ContactInfo.java
When two phones exchange information via Bluetooth, in addition to random IDs, they will also store the distance
and time of that contact. We want to create a class ContactInfo , in the file ContactInfo.java , to hold all the
information used for the exchange.
TODO: Instance Variables for ContactInfo
Each ContactInfo object will be able to store only one id , which means we will need to create two ContactInfo
object in one exchange. We will use this in Part 4.
id stores the (random) ID that is sent (to the other student).
distance stores the distance between the two students and should always be non-negative.
time stores the time this contact happens.
used stores whether this contact information has been used to send out an exposure notification.
1 public class ContactInfo {...}
public class ContactInfo {
...
public int id;
public int distance;
public int time;
public boolean used;
...
}
TODO: Methods to Implement for ContactInfo
This ContactInfo class only has one constructor and one method. The constructor initializes the instance variables
and isValid() checks if the instance variables are valid. You can think of this as meaning that when information is
exchanged, we call the constructor locally, but the information might be invalid because it was corrupted before it
arrived.
public ContactInfo(int id, int distance, int time)
This is the constructor for ContactInfo .
Initialize used to false and initialize all other instance variables with the values from parameters. Do not do
any validity checking here for this constructor.
public boolean isValid()
Check if all the values of the instance variables are valid as specified in Part 0.
Return false if any of the instance variables is invalid. Return true if all the instance variables are valid. Here,
used can take either boolean value so it is always valid.
public class ContactInfo {
...
public ContactInfo(int id, int distance, int time);
public boolean isValid();
...
}
Part 2: Server.java
You will need to create a Server class, in the file Server.java , to represent the server that stores all recent IDs from
COVID-19 positive users. The server will only support two operations: adding new IDs and getting all stored IDs.
TODO: Instance Variable for Server
infectedIds stores the IDs in the order that they are added to the server, with the first being at index 0 and the
latest being at the end of the list.
TODO: Methods to Implement for Server
public Server()
This is the no-arg constructor for Server .
Initialize infectedIds with a new (empty) ArrayList .
public boolean addInfectedIds(ArrayList<Integer> ids)
Add every ID from ids into infectedIds in the order they appear (first at index 0, last at the end) and return
true to indicate adding is successful.
If ids is null , return false to indicate adding failed without modifying anything. Do not do anything special
for null values inside ids .
1 public class Server {...}
public class Server {
...
public ArrayList<Integer> infectedIds;
...
}
public class Server {
...
public Server();
public boolean addInfectedIds(ArrayList<Integer> ids);
public ArrayList<Integer> getInfectedIds();
...
}
public ArrayList<Integer> getInfectedIds()
Return a deep copy of infectedIds . This means that you should create a new ArrayList and fill it with the
exact elements in infectedIds - this way, if someone modifies the returned list, the instance variable will not be
affected.
Note: we can assume that infectedIds will never be null when this method is called. Also, we would usually
see infectedIds as a private instance variable but we are leaving it as public for testing purposes.
Part 3: Student.java
Ideally, we would create a class representing phones to handle ID exchanges and a class representing students to
handle movements and COVID-19 test status, but for the sake of simplicity, we will just create one Student class, in
the file Student.java , to handle both ID exchanges and student-related functionality in this PA.
TODO: Instance Variables for Student
id stores the (random) current ID of the student.
location stores the current location of the student.
covidPositive stores an indicator for if the student has tested positive.
inQuarantine stores an indicator for if the student is in quarantine (and therefore cannot move).
usedIds stores all of the random IDs that the student has used so far, in order, with the first ID at index 0 and
the most recent one (the one currently stored in id ) at the end of the list.
contactHistory stores the ContactInfo objects that were sent to this student (in an exchange in Part 4) in the
order they were received, with the first received at index 0 and the most recent one at the end of the list.
1 public class Student {...}
public class Student {
...
public int id;
public int location;
public boolean covidPositive;
public boolean inQuarantine;
public ArrayList<Integer> usedIds;
public ArrayList<ContactInfo> contactHistory;
...
}
TODO: Methods to Implement for Student
We will implement all of these instance methods for the Student class to facilitate updating each object and for
doing some computations based on the current state of each object. Each method should have the behavior that is
specified and all instance variables should be updated or left unmodified as necessary so that future method calls
operate on correct instance variables.
public Student()
This is the no-arg constructor for Student .
Initialize all instance variables properly in this constructor.
id and location should both be -1 . We intentionally set id and location to an invalid value to indicate
that the student is not ready for simulation.
covidPostive and inQuarantine should be false , since we are assuming that all students are not infected
at the beginning of the simulation.
usedIds and contactHistory should each be initialized with a new (empty) ArrayList .
public boolean setLocation(int newLocation)
If newLocation is valid and inQuarantine is false , update the instance variable location with the new value
from newLocation and return true .
Otherwise, return false , without modifying the location instance variable, to indicate setting location failed.
public void updateId()
Update id with a new random integer within the range [0, Integer.MAX_VALUE ). The method should also
store this new id in the usedIds list. You can read about how to generate a random number here.
public class Student {
...
public Student();
public boolean setLocation(int newLocation);
public void updateId();
public boolean addContactInfo(ContactInfo info);
public boolean uploadAllUsedIds(Server server);
public boolean testPositive(Server server);
public ArrayList<ContactInfo> getRecentPositiveContacts(Server server,
int fromTime);
public int riskCheck(Server server, int fromTime, boolean quarantineChoice);
...
}
public boolean addContactInfo(ContactInfo info)
If info is non- null and valid (as specified in Part 1), add info to the end of the contactHistory list and return
true .
Otherwise, return false to indicate that adding contact information failed.
public boolean uploadAllUsedIds(Server server)
If server is not null , add all IDs in this Student object's usedIds list into the server , by calling server 's
addInfectedIds() method, and return whether addInfectedIds() executed successfully.
Otherwise (if server is null ), return false without doing anything, indicating that uploading failed.
public boolean testPositive(Server server)
Update covidPositive and inQuarantine to be true (calling this method indicates that the student has tested
positive). This should be done even if server is null .
Then, upload this Student 's used ids to server by calling uploadAllUsedIds() and return whether
uploadAllUsedIds() executed successfully or not. If uploadAllUserIds() cannot be called, return false too.
public ArrayList<ContactInfo> getRecentPositiveContacts(Server server, int fromTime)
Get all "infected" IDs from the server by calling getInfectedIds() in the Server class (make sure you are not
directly accessing the instance variable), and check contactHistory against them. Return a sublist of
contactHistory where each ContactInfo in the sublist satisfies the following conditions:
its used is false
its id is in the "infected" ID list
its time is greater than or equal to fromTime
There are several invalid inputs or states. If any of these occurs, return null instead:
server is null
fromTime is invalid (i.e., it is negative)
getInfectedIds() returns null
public int riskCheck(Server server, int fromTime, boolean quarantineChoice)
Assess the student's risk of having COVID-19 and simulate notifiying the student by letting them choose to selfquarantine.
Do so following these steps:
1. Get all recent contacts with positive cases by calling getRecentPositiveContacts() with the appropriate
arguments. If getRecentPositiveContacts() returns null , return -1 without proceeding.
2. Analyze this student's risk of having COVID-19 based on the recent positive contacts. Any ContactInfo
that results in this student being assessed as high-risk should be marked as "used" (the used instance
variable should be set to true ). A student is in high-risk if at least one of the conditions below is true:
the student has at least one recent contact who tested positive and this contact had distance less
than or equal to 1 . Any ContactInfo satisfying this should be marked as used.
the student has three or more recent contacts who tested positive (regardless of distances). If this
condition is satisfied, all ContactInfo s should be marked as used.
3. If the student is assessed as high-risk, update inQuarantine to true if quarantineChoice is true and
then return 1 regardless of quarantineChoice . If the student is not assessed as high-risk, return 0
instead.
Part 4: Simulator.java
Finally, we will need a Simulator class to simulate student interactions using the Exposure Notification System we
just built. Fortunately, we have written a Simulator for you in Simulator.java . Even though you don't need to
implement the Simulator, you still need to read through the Simulator class carefully and answer README
questions about the Simulator class on Gradescope.
Simulator will read data from an input file where each line contains some integers separated by comma. All the lines
in the file have the same length, which represents the number of students in this simulation. For example, an input file
might have the following content:
Since each line has five numbers, we will have five students for this simulation. Each column contains all the data for
one specific student.
The first line shows each student's choice of whether going into a quarantine when they are notified of being in
contact with COVID positive cases.
The second line and the third line are the data for the first day. The second line shows the locations for each student.
The third line shows whether a student is tested positive or not ( 1 means positive).
The fourth line and the fifth line similarly are the data for the second day. Similarly, any further days will be two more
lines each.
In summary, this example input file means:
0,0,0,0,1 --> Five students and their choices for quarantine
1,1,1,4,4 --> locations for day 0 (e.g. the first student is at 1)
0,0,0,0,0 --> infection status for day 0 (no one is infected in this cae)
2,0,3,4,5 --> locations for day 1 (e.g. the first student now is at 2)
1,0,0,0,0 --> infection status for day 1 (the first student is tested positive)
Methods and Instance Variables for Simulator
public class Simulator {
...
public ArrayList<Student> students;
public Server server;

public Simulator(int num);
public void updateIds();
public boolean updateLocations(ArrayList<Integer> locations);
public boolean updateInfectionStatus(ArrayList<Integer> infections);
public int riskCheckAll(ArrayList<Integer> quarantineChoices, int fromTime);
public boolean exchangeInfo(Student student1, Student student2, int currentTime);
public int simulateOneDay(ArrayList<Integer> locations, ArrayList<Integer> infections, ArrayList<Integer>
quarantineChoices, int time);
public static void main() throws IOException;
...
}
Tips
This PA is relatively complex and many methods depend on other methods, so debugging the whole program
would be hard. We highly recommend writing a main method or a test class for each class to test each method
individually. You will either need to delete the main method when turning in your assignment or ensure that
your main method follows the style guide (except the magic number rule).
When we test your code, we will unit test each method individually so you can safely use all other methods. For
example, you need to call getRecentPositiveContacts() in riskCheck() . When we test your riskCheck() , we
will use our correct version of getRecentPositiveContacts() .
You can use the provided Simulator.java as an example of how methods you implemented in other classes
(especially Student class) will be used.
All files (all .java files and the sample.txt ) should be in the same directory.
To run the simulator, you need to compile all .java files (having their .class files) and run java Simulator .
Feel free to create your own testing classes to try out the simulator or any other classes.
Feel free to modify the content in the input file to test your code.
Style
Coding style is an important part of ensuring readability and maintainability of your code. We will grade your code
style in all submitted code files according to the style guidelines. Namely, there are a few things you must have in
each file/class/method:
1. File headers
2. Class headers
3. Method headers
4. Inline comments
5. Proper indentation (do not intermingle spaces and tabs for indentation)
6. Descriptive variable names
7. No magic numbers (exception: main() for testing purposes)
8. Reasonably short methods (if you have implemented each method according to specification in this write-up,
you’re fine)
9. Lines shorter than 80 characters (note, tabs will be counted as 4 characters toward this limit. It is a good idea to
set your tab width/size to be 4)
10. Javadoc conventions (@param, @return tags, /** header comments */, etc.)
A full style guide can be found here. In addition, an example of a properly styled Java file has been posted on Piazza.
If you need any clarifications, feel free to ask on Piazza.
README
All the questions for the README portion of this assignment can be found on Gradescope. Note that this portion of
the assignment cannot be submitted late.
For this PA, README questions are about the Simulator class that we provide you, so you should read through
Simulator.java carefully before answering the README questions.
Survey
Please fill out this survey, worth 1 point to your PA grade, to help us improve the experience of this class!
Weekly Reflection 6.
Submission
Turning in your code
Submit all of the following files to Gradescope by Wednesday, Nov 18 @ 11:59PM PST (Thursday, Nov 19 @
11:59PM PST w/ slip day):
ContactInfo.java
Server.java
Student.java
When submitting, please wait until the autograder finishes running and read the output. Your code must compile in
the autograder in order to receive proper partial credit.
Evaluation
1. Correctness (80 points) You will earn points based on the autograder tests that your code passes. If the
autograder tests are not able to run (e.g., your code does not compile or it does not match the specifications in
this writeup), you may not earn credit.
2. Coding Style (10 points)
3. README (9 points)
4. Weekly Reflection Survey (1 point)


关闭窗口
上一篇:代写CSC424编程语言、代做program实验编程、代写Python,Java程序
下一篇: Python代做_作业代写_python代考

相关阅读


代写
微信

微信客服

微信客服:EG1hao

山东济南市历下区三庆财富中心

qq

QQ客服

QQ联系:3029629821