From 5d33269b15e2935102aa51b2460306632df129c2 Mon Sep 17 00:00:00 2001 From: IvanaE Date: Fri, 16 Nov 2018 16:06:32 -0500 Subject: [PATCH] secondary constructor --- .../uottawa/olympus/olympusservices/DBHelper.java | 3 +-- .../olympus/olympusservices/ServiceProvider.java | 13 +++++++++++++ .../olympusservices/ServiceProviderTest2.java | 3 +-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/DBHelper.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/DBHelper.java index 5cb714e..6d0e729 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/DBHelper.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/DBHelper.java @@ -309,10 +309,9 @@ public class DBHelper extends SQLiteOpenHelper { usertype = new Admin(); } else if (cursor.getString(4) .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); getAvailabilities(serviceProvider); - serviceProvider.setDescription(description); usertype = serviceProvider; } else { usertype = new HomeOwner(username, password, firstname, lastname); diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProvider.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProvider.java index efc36c5..16f190c 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProvider.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProvider.java @@ -52,6 +52,19 @@ public class ServiceProvider extends UserType { this.phonenumber = phonenumber; this.companyname = companyname; 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; } /** diff --git a/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/ServiceProviderTest2.java b/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/ServiceProviderTest2.java index ec15e4a..1491881 100644 --- a/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/ServiceProviderTest2.java +++ b/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/ServiceProviderTest2.java @@ -6,7 +6,7 @@ import static org.junit.Assert.*; public class ServiceProviderTest2 { 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 public void testOtherInstances() { - serviceprovider.setDescription("LOL"); assertEquals( "testaddress", serviceprovider.getAddress() ); assertEquals( "8888888888", serviceprovider.getPhonenumber() ); assertEquals( "companydotcom", serviceprovider.getCompanyname() );