-
Notifications
You must be signed in to change notification settings - Fork 0
/
ContactInfo.java
61 lines (60 loc) · 2.03 KB
/
ContactInfo.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
/**
* This ContactInfo class is a class to hold all the information used for
* the exchange of information via Bluetooth. This class works in
* conjunction with the Server class and Student class to simulate an
* Exposure Notifications System that can quickly notify registered users
* about their recent close contact with COVID-19 infected people
**/
import java.util.*;
/**
* This class holds all of the information needed to exchange information
* via bluetooth for the app this includes: id, distance, time, used
*/
public class ContactInfo {
/**
* These are the instance variables for the class
*
* @param id stores the (random) ID that is sent (to the other student).
* @param distance stores the distance between the two students and should
* always be non-negative.
* @param time stores the time this contact happens.
* @param used stores whether this contact information has been used to
* send out an exposure notification.
*/
public int id;
public int distance;
public int time;
public boolean used;
/**
* This is the main constructor method that initializes the values of the
* instance variables
*
* @param id stores the (random) ID that is sent (to the other student).
* @param distance stores the distance between the two students and should
* always be non-negative.
* @param time stores the time this contact happens.
* @param used stores whether this contact information has been used to
* send out an exposure notification.
*/
public ContactInfo(int id, int distance, int time){
this.id = id;
this.distance = distance;
this.time = time;
this.used = false;
}
/**
* This isValid method is a method that checks if the instance variables are
* valid
*
* @param distance stores the distance between the two students and should
* always be non-negative.
* @param time stores the time this contact happens.
* @return whether the instance variables are valid
*/
public boolean isValid(){
if(distance<0||time<0){
return false;
}
return true;
}
}