Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class LifestyleTracker {
- ArrayList <Food> food;
- ArrayList <Activity> activity;
- ArrayList <Activity> activitycalories;
- public LifestyleTracker() {
- food = new ArrayList<Food>();
- activity = new ArrayList<Activity>();
- }
- public String addFood(String n, double c) {
- food.add(new Food(n, c));
- String temp = "Added Food" + n ;
- return temp;
- }
- public String addActivity(String n, double c) {
- activity.add(new Activity(n,c));
- String temp = "Added Activity" + n;
- return temp;
- }
- public String eat(String fn, double servings) {
- if (servings < 0) {
- System.out.println("Number of servings cannot be negative");
- }
- else {
- for(int x = 0; x < food.size(); x++) {
- if( food.get(x).getFoodName().equals(fn)) {
- String temp = "Ate" + fn;
- return temp;
- }
- else {
- String feedback = "The specific food does not exist";
- return feedback;
- }
- }
- }
- }
- public String perform(String act, double hours) {
- if (hours < 0) {
- System.out.println("Number of servings cannot be negative");
- }
- else {
- for(int x = 0; x < activity.size(); x++) {
- if( activity.get(x).getActivityName().equals(act)) {
- String temp = "Performed" + act;
- return temp;
- }
- else {
- String feedback = "The specific food does not exist";
- return feedback;
- }
- }
- }
- }
- public String report() {
- String feedback = "finished";
- return feedback;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement