Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. import java.util.ArrayList;
  2. public class LifestyleTracker {
  3. ArrayList <Food> food;
  4.  
  5. ArrayList <Activity> activity;
  6. ArrayList <Activity> activitycalories;
  7. public LifestyleTracker() {
  8. food = new ArrayList<Food>();
  9. activity = new ArrayList<Activity>();
  10. }
  11.  
  12. public String addFood(String n, double c) {
  13. food.add(new Food(n, c));
  14. String temp = "Added Food" + n ;
  15. return temp;
  16.  
  17. }
  18. public String addActivity(String n, double c) {
  19. activity.add(new Activity(n,c));
  20. String temp = "Added Activity" + n;
  21. return temp;
  22. }
  23. public String eat(String fn, double servings) {
  24.  
  25. if (servings < 0) {
  26. System.out.println("Number of servings cannot be negative");
  27. }
  28. else {
  29. for(int x = 0; x < food.size(); x++) {
  30. if( food.get(x).getFoodName().equals(fn)) {
  31. String temp = "Ate" + fn;
  32. return temp;
  33. }
  34. else {
  35. String feedback = "The specific food does not exist";
  36. return feedback;
  37. }
  38. }
  39. }
  40.  
  41.  
  42. }
  43. public String perform(String act, double hours) {
  44. if (hours < 0) {
  45. System.out.println("Number of servings cannot be negative");
  46. }
  47. else {
  48. for(int x = 0; x < activity.size(); x++) {
  49. if( activity.get(x).getActivityName().equals(act)) {
  50. String temp = "Performed" + act;
  51. return temp;
  52. }
  53. else {
  54. String feedback = "The specific food does not exist";
  55. return feedback;
  56. }
  57. }
  58. }
  59.  
  60.  
  61. }
  62. public String report() {
  63. String feedback = "finished";
  64.  
  65. return feedback;
  66.  
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement