use of com.example.peter.homelessapp.model.Shelter in project FindMyHome by DjangoBlockchained.
the class UserUnitTest method testEquals.
@Test
public void testEquals() {
User a = new HomelessUser();
User b = new HomelessUser();
// if both usernames are null, return false
assertFalse(a.equals(b));
// different names, null usernames - still false (obv)
a.setName("Sanjana");
b.setName("Peter");
assertFalse((a.equals(b)));
// same names, null usernames - still false
b.setName("Sanjana");
// a.getName() = sanjana
assertFalse(a.equals(b));
// same names, one username null - false
b.setUsername("pzupke3");
// a.getUsername() = NULL
assertFalse((a.equals(b)));
// same names, different non-null usernames - false
a.setUsername("skadivet6");
// b.getUsername() = pzupke3
assertFalse((a.equals(b)));
// same names, same non-null usernames - true!
a.setUsername("pzupke3");
// b.getUsername() = pzupke3
assertTrue(a.equals(b));
// different names, same non-null usernames - true!
b.setName("Peter");
assertTrue((a.equals(b)));
// same objects, true!
b = a;
assertTrue(a.equals(b));
// one of the objects is null - false
b = null;
assertFalse((a.equals(b)));
// one of the objects not an instance of user - false
Shelter x = new Shelter();
assertFalse((a.equals(x)));
}
use of com.example.peter.homelessapp.model.Shelter in project FindMyHome by DjangoBlockchained.
the class AdminScreenActivity method readShelters.
private void readShelters() {
try {
InputStream is = getResources().openRawResource(R.raw.shelters);
BufferedReader br1 = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
br1.readLine();
String s = br1.readLine();
while (s != null) {
String[] tokens = s.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)");
Integer capacity = Shelter.parseCapacity(tokens[2]);
new Shelter(tokens[0], tokens[1], capacity, tokens[3], Double.parseDouble(tokens[4]), Double.parseDouble(tokens[5]), tokens[6], tokens[7], tokens[8]);
s = br1.readLine();
}
br1.close();
} catch (IOException e) {
android.util.Log.d("", "error!");
}
}
use of com.example.peter.homelessapp.model.Shelter in project FindMyHome by DjangoBlockchained.
the class ApplicationScreenActivity method readShelters.
private void readShelters() {
try {
InputStream is = getResources().openRawResource(R.raw.shelters);
BufferedReader br1 = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
br1.readLine();
String s = br1.readLine();
while (s != null) {
String[] tokens = s.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)");
Integer capacity = Shelter.parseCapacity(tokens[2]);
new Shelter(tokens[0], tokens[1], capacity, tokens[3], Double.parseDouble(tokens[4]), Double.parseDouble(tokens[5]), tokens[6], tokens[7], tokens[8]);
s = br1.readLine();
}
br1.close();
} catch (IOException e) {
android.util.Log.d("", "error!");
}
}
use of com.example.peter.homelessapp.model.Shelter in project FindMyHome by DjangoBlockchained.
the class ClaimScreenActivity method showAlreadyCheckedInAlert.
private void showAlreadyCheckedInAlert(int beds, String currentShelter) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Already Checked In");
builder.setMessage("You are already checked in to the shelter '" + currentShelter + "'. Would you like to check out and check in to the new shelter?");
builder.setPositiveButton("Check Out", (dialog, id) -> {
shelterRef = FirebaseDatabase.getInstance().getReference().child("shelters").child(// .getParent();
currentShelter);
shelterRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Shelter currShelter = dataSnapshot.getValue(Shelter.class);
if (currShelter == null) {
return;
}
Shelter.checkOut(shelter, currShelter, currentUser);
checkIn(beds);
dialog.dismiss();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
});
builder.setNegativeButton("Cancel", (dialog, id) -> dialog.dismiss());
builder.create().show();
}
use of com.example.peter.homelessapp.model.Shelter in project FindMyHome by DjangoBlockchained.
the class checkOutTest method test.
@Test
public void test() throws Exception {
HomelessUser test = new HomelessUser();
Shelter s = new Shelter();
s.setCapacity(1);
s.checkIn(test, 1);
assert (s.checkOut(test));
assert (!s.checkOut(test));
}
Aggregations