secondary constructor
This commit is contained in:
parent
60c1329bcd
commit
5d33269b15
3 changed files with 15 additions and 4 deletions
|
@ -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);
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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() );
|
||||||
|
|
Loading…
Reference in a new issue