improved IFavorites and TestFavorites
This commit is contained in:
parent
0d04bdadc2
commit
b24fc37dc3
@ -1,21 +0,0 @@
|
||||
package com.example.aped.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Favorites implements IFAVORITES{
|
||||
|
||||
@Override
|
||||
public List<String> getFavorites() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String addFavorite(String deviceName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String removeFavorite(String deviceName) {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -2,8 +2,28 @@ package com.example.aped.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Interface for managing the favorites.
|
||||
*/
|
||||
public interface IFAVORITES {
|
||||
|
||||
/**
|
||||
* Returns the names of the favorite devices.
|
||||
* @return list of strings
|
||||
*/
|
||||
List<String> getFavorites();
|
||||
|
||||
/**
|
||||
* Adds a favorite to the list.
|
||||
* @param deviceName the name of the device to be added
|
||||
* @return the name of the device addition worked
|
||||
*/
|
||||
String addFavorite(String deviceName);
|
||||
|
||||
/**
|
||||
* Removes a device from the favorite list.
|
||||
* @param deviceName the name of the device to be removed
|
||||
* @return the name of the device if the removal worked
|
||||
*/
|
||||
String removeFavorite(String deviceName);
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.example.aped.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TestFavorites implements IFAVORITES{
|
||||
|
||||
private List<String> favorites = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public List<String> getFavorites() {
|
||||
return favorites;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String addFavorite(String deviceName) {
|
||||
if (!favorites.contains(deviceName)) {
|
||||
favorites.add(deviceName);
|
||||
}
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String removeFavorite(String deviceName) {
|
||||
if (favorites.contains(deviceName)) {
|
||||
favorites.remove(deviceName);
|
||||
}
|
||||
return deviceName;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user