how about now?

This commit is contained in:
IvanaE 2018-11-13 13:49:26 -05:00
parent 3e555f0b41
commit a422c6fc3d
2 changed files with 19 additions and 3 deletions

View file

@ -6,6 +6,7 @@ import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Toast;
public class SignUpPart2 extends AppCompatActivity { public class SignUpPart2 extends AppCompatActivity {
private String username; private String username;
@ -32,8 +33,22 @@ public class SignUpPart2 extends AppCompatActivity {
String address = ((EditText) findViewById(R.id.AddressInput)).getText().toString(); String address = ((EditText) findViewById(R.id.AddressInput)).getText().toString();
boolean licensed = ((CheckBox) findViewById(R.id.LicensedInput)).isChecked(); boolean licensed = ((CheckBox) findViewById(R.id.LicensedInput)).isChecked();
ServiceProvider serviceProvider = new ServiceProvider(username, password, firstname, lastname, if(companyname.length()>0 && address.length()>0 && phonenumber.length()>0
address, phonenumber, companyname, licensed); && companyname.matches("[a-zA-Z0-9]*") && address.matches("[a-zA-Z]*")
&& phonenumber.matches("^(\\+\\d{1,2}\\s)?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4}$")) {
ServiceProvider serviceProvider = new ServiceProvider(username, password, firstname, lastname,
address, phonenumber, companyname, licensed);
if(dbHelper.addUser(serviceProvider)){
startActivity(intent);
finish();
}else{
Toast.makeText(this,"Could not create account",Toast.LENGTH_LONG).show();
}
}
else{
Toast.makeText(this, "Fields cannot be empty and must be formatted correctly", Toast.LENGTH_LONG).show();
}
} }
} }

View file

@ -8,7 +8,8 @@ import static org.junit.Assert.*;
public class ServiceProviderTest { public class ServiceProviderTest {
ServiceProvider serviceprovider = new ServiceProvider("John123", "1234567890", "John", "Doe"); ServiceProvider serviceprovider = new ServiceProvider("John123", "1234567890", "John", "Doe",
"testaddress", "8888888888", "companydotcom", true);
/** /**
* Initiates an ServiceProvider account and tests if the random strings match to the required inputs. * Initiates an ServiceProvider account and tests if the random strings match to the required inputs.