secondary constructor

This commit is contained in:
IvanaE 2018-11-16 16:06:32 -05:00
parent 2117d58685
commit 04829231e2
3 changed files with 15 additions and 4 deletions

View file

@ -309,10 +309,9 @@ public class DBHelper extends SQLiteOpenHelper {
usertype = new Admin(); usertype = new Admin();
} else if (cursor.getString(4) } else if (cursor.getString(4)
.equals("ServiceProvider")){ .equals("ServiceProvider")){
ServiceProvider serviceProvider = new ServiceProvider(username, password, firstname, lastname, address, phonenumber, companyname, licensed); ServiceProvider serviceProvider = new ServiceProvider(username, password, firstname, lastname, address, phonenumber, companyname, licensed, description);
getAllServicesProvidedByUser(serviceProvider); getAllServicesProvidedByUser(serviceProvider);
getAvailabilities(serviceProvider); getAvailabilities(serviceProvider);
serviceProvider.setDescription(description);
usertype = serviceProvider; usertype = serviceProvider;
} else { } else {
usertype = new HomeOwner(username, password, firstname, lastname); usertype = new HomeOwner(username, password, firstname, lastname);

View file

@ -52,6 +52,19 @@ public class ServiceProvider extends UserType {
this.phonenumber = phonenumber; this.phonenumber = phonenumber;
this.companyname = companyname; this.companyname = companyname;
this.licensed = licensed; this.licensed = licensed;
this.description = "";
}
ServiceProvider(String username, String password, String firstname, String lastname, String address,
String phonenumber, String companyname, boolean licensed, String description){
super(username, password, firstname, lastname);
services = new ArrayList<>();
availabilities = new int[7][4];
this.address = address;
this.phonenumber = phonenumber;
this.companyname = companyname;
this.licensed = licensed;
this.description = description;
} }
/** /**

View file

@ -6,7 +6,7 @@ import static org.junit.Assert.*;
public class ServiceProviderTest2 { public class ServiceProviderTest2 {
ServiceProvider serviceprovider = new ServiceProvider("John123", "1234567890", "John", "Doe", ServiceProvider serviceprovider = new ServiceProvider("John123", "1234567890", "John", "Doe",
"testaddress", "8888888888", "companydotcom", true); "testaddress", "8888888888", "companydotcom", true, "LOL");
/** /**
@ -30,7 +30,6 @@ public class ServiceProviderTest2 {
*/ */
@Test @Test
public void testOtherInstances() { public void testOtherInstances() {
serviceprovider.setDescription("LOL");
assertEquals( "testaddress", serviceprovider.getAddress() ); assertEquals( "testaddress", serviceprovider.getAddress() );
assertEquals( "8888888888", serviceprovider.getPhonenumber() ); assertEquals( "8888888888", serviceprovider.getPhonenumber() );
assertEquals( "companydotcom", serviceprovider.getCompanyname() ); assertEquals( "companydotcom", serviceprovider.getCompanyname() );