diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Service.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Service.java index d3b7c03..266115a 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Service.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Service.java @@ -1,12 +1,17 @@ package com.uottawa.olympus.olympusservices; +import java.util.ArrayList; +import java.util.List; + public class Service { private String name; private double rate; + private List serviceProviders; Service(String name, double rate) { this.name = name; this.rate = rate; + serviceProviders = new ArrayList(); } public String getName() { @@ -24,4 +29,18 @@ public class Service { public void setRate(double rate) { this.rate = rate; } + + public boolean addServiceProvider(ServiceProvider user){ + for (ServiceProvider listUser : serviceProviders){ + if (user.getUsername().equals(listUser.getUsername())){ + return false; + } + } + serviceProviders.add(user); + return true; + } + + public List getServiceProviders(){ + return serviceProviders; + } } 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 086ccf0..15bfde4 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 @@ -1,12 +1,31 @@ package com.uottawa.olympus.olympusservices; +import java.util.ArrayList; +import java.util.List; + public class ServiceProvider extends UserType { + private List services; + ServiceProvider(String username, String password, String firstname, String lastname){ super(username, password, firstname, lastname); + services = new ArrayList<>(); } public String getRole(){ return "ServiceProvider"; } + public boolean addService(Service service){ + for (Service listService : services){ + if (service.getName().equals(listService.getName())){ + return false; + } + } + services.add(service); + return true; + } + + public List getServices(){ + return services; + } } diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java index e070cb1..8f29a44 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java @@ -29,7 +29,7 @@ public class ServicesList extends AppCompatActivity implements NewServiceDialogF services[(i+1)*2] = current[0]; services[(i+1)*2+1] = current[1]; } - ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, services); + ArrayAdapter adapter = new ArrayAdapter(this, R.layout.simple_list_item_1_customized, services); GridView gridView = findViewById(R.id.Services); gridView.setAdapter(adapter); gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UsersList.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UsersList.java index e7bbff4..4cb5afb 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UsersList.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UsersList.java @@ -26,7 +26,7 @@ public class UsersList extends AppCompatActivity { usernames[(i+1)*2] = current[0]; usernames[(i+1)*2+1] = current[3]; } - ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, usernames); + ArrayAdapter adapter = new ArrayAdapter(this, R.layout.simple_list_item_1_customized, usernames); GridView gridView = findViewById(R.id.Users); gridView.setAdapter(adapter); } diff --git a/OlympusServices/app/src/main/res/layout/simple_list_item_1_customized.xml b/OlympusServices/app/src/main/res/layout/simple_list_item_1_customized.xml new file mode 100644 index 0000000..9847704 --- /dev/null +++ b/OlympusServices/app/src/main/res/layout/simple_list_item_1_customized.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file