refactored user to homeowner

This commit is contained in:
IvanaE 2018-10-30 11:08:08 -04:00
parent fd2cf0fe0d
commit fece5c7758
7 changed files with 25 additions and 25 deletions

View file

@ -25,7 +25,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View file

@ -155,7 +155,7 @@ public class DBHelper extends SQLiteOpenHelper {
.equals("ServiceProvider")){
usertype = new ServiceProvider(username, password, firstname, lastname);
} else {
usertype = new User(username, password, firstname, lastname);
usertype = new HomeOwner(username, password, firstname, lastname);
}
} else {
usertype = null;

View file

@ -0,0 +1,12 @@
package com.uottawa.olympus.olympusservices;
public class HomeOwner extends UserType {
HomeOwner(String username, String password, String firstname, String lastname){
super(username, password, firstname, lastname);
}
public String getRole(){ return "HomeOwner"; }
}

View file

@ -15,7 +15,7 @@ public class SignUp extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
MaterialSpinner spinner = findViewById(R.id.RoleInput);
spinner.setItems("User", "Service Provider");
spinner.setItems("HomeOwner", "Service Provider");
spinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() {
@Override public void onItemSelected(MaterialSpinner view, int position, long id, String item) {
@ -36,14 +36,14 @@ public class SignUp extends AppCompatActivity {
if(username.length()>=5 && password.length()>5 && firstname.length()>0 && lastname.length()>0 && username.matches("[a-zA-Z0-9]*") && password.matches("[a-zA-Z0-9]*")
&& firstname.matches("[a-zA-Z]*") && lastname.matches("[a-zA-Z]*")){
switch(spinner.getText().toString()){
case "User":
newUser = new User(username,password,firstname,lastname);
case "HomeOwner":
newUser = new HomeOwner(username,password,firstname,lastname);
break;
case "Service Provider":
newUser = new ServiceProvider(username,password,firstname,lastname);
break;
default:
newUser = new User(username,password,firstname,lastname); //if nothing is enter then defaults to user role.
newUser = new HomeOwner(username,password,firstname,lastname); //if nothing is enter then defaults to user role.
break;
}

View file

@ -1,12 +0,0 @@
package com.uottawa.olympus.olympusservices;
public class User extends UserType {
User(String username, String password, String firstname, String lastname){
super(username, password, firstname, lastname);
}
public String getRole(){ return "User"; }
}

View file

@ -19,7 +19,7 @@ public class UsersList extends AppCompatActivity {
List<String[]> users = dbHelper.getAllUsers();
String[] usernames = new String[(users.size()+1)*2];
usernames[0] = "Username";
usernames[1] = "User Type";
usernames[1] = "HomeOwner Type";
Iterator iter = users.iterator();
for (int i=0; i<users.size();i++){
String[] current = (String[])iter.next();

View file

@ -37,11 +37,11 @@ public class DBIntegrationTest {
boolean deleted, addedOne, addedTwo;
originalUser = new User("mgarzon", "soccer", "Miguel", "Garzon");
originalUser = new HomeOwner("mgarzon", "soccer", "Miguel", "Garzon");
addedOne = dbHelper.addUser(originalUser);
dbUser = dbHelper.findUserByUsername("mgarzon");
assertEquals("User", dbUser.getClass().getSimpleName());
assertEquals("HomeOwner", dbUser.getClass().getSimpleName());
assertEquals("mgarzon", dbUser.getUsername());
assertEquals("soccer", dbUser.getPassword());
assertEquals("Miguel", dbUser.getFirstname());
@ -75,9 +75,9 @@ public class DBIntegrationTest {
public void testAddDuplicateUsers(){
boolean added;
added = dbHelper.addUser(new User("jbO4aBF4dC", "soccer", "Miguel", "Garzon"));
added = dbHelper.addUser(new HomeOwner("jbO4aBF4dC", "soccer", "Miguel", "Garzon"));
assertTrue(added);
added = dbHelper.addUser(new User("jbO4aBF4dC", "seg2105", "Miguel", "Garzon"));
added = dbHelper.addUser(new HomeOwner("jbO4aBF4dC", "seg2105", "Miguel", "Garzon"));
assertTrue(!added);
added = dbHelper.addUser(new ServiceProvider("jbO4aBF4dC", "seg2105", "Juan", "Guzman"));
assertTrue(!added);
@ -90,7 +90,7 @@ public class DBIntegrationTest {
boolean updated;
UserType dbUser;
dbHelper.addUser(new User("jbO4aBF4dC", "soccer", "Miguel", "Garzon"));
dbHelper.addUser(new HomeOwner("jbO4aBF4dC", "soccer", "Miguel", "Garzon"));
updated = dbHelper.updateUserInfo("jbO4aBF4dC", "soccer", "Juan", "Guzman");
assertTrue(updated);
@ -110,7 +110,7 @@ public class DBIntegrationTest {
@Test
public void testGetAllUsers(){
dbHelper.addUser(new User("jbO4aBF4dC", "soccer", "Miguel", "Garzon"));
dbHelper.addUser(new HomeOwner("jbO4aBF4dC", "soccer", "Miguel", "Garzon"));
List<String[]> allUsers = dbHelper.getAllUsers();