I'm working on this project and I'm in the process of creating the searchStore() method in User class but I can't think of any way to access the cost of the candies in a certain store.

When the user searches for a store, the program should print the stores that is nearby the landmarks, so if the user visits the lm 4 and lm1, Lolli's and Guccini's store would print. I need to access the cost of the candies in the store to check if the money of the user is enough to buy a candy. If the money is sufficient, then it should print that the user can buy a candy in the store, else it should prompt that the money is not enough to buy a candy.

I tried to create an instance inside the method but that's not correct because if I am to make a new instance, I'm not accessing the cost of the store that I want, but the cost of the instance that I created.

I also tried the getter method in the CandyStore class but it says that I should make the attribute cost static but that is not possible because the cost varies in different stores.

Can someone help me to implement the searchStore method in User class?

**MAIN CLASS**

```
package testing;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.out.println("Hello World");

        User user1 = new User("Mylah", 1, 20f);
        User user2 = new User("Meg", 2, 50f);
        User user3 = new User("Marga", 3, 25f);

        Landmark lm1 = new Landmark("Vista Mall", 1);
        Landmark lm2 = new Landmark("Vista Residences", 2);
        Landmark lm3 = new Landmark("Vista Park", 3);

        Landmark lm4 = new Landmark("Crystal Mall", 4);
        Landmark lm5 = new Landmark("Crystal Residences", 5);
        Landmark lm6 = new Landmark("Crystal Park", 6);

        CandyStore c1 = new CandyStore("Lolli's Store", 1, 15);
        CandyStore c2 = new CandyStore("Mary's Store", 2, 25);
        CandyStore c3 = new CandyStore("Guccini's Store", 3, 10);

        c1.addLandmark(lm4);
        c1.addLandmark(lm6);
        c2.addLandmark(lm2);
        c2.addLandmark(lm3);
        c3.addLandmark(lm1);
        c3.addLandmark(lm5);

        user1.visits(lm4);
        user1.visits(lm1);

        user1.searchStore();
        user1.viewState();
    }

}

```

**USER CLASS**

```
package testing;

public class User {
    String name;
    int StudentId;
    float money;
    Landmark[] lm;
    int lmCounter;
    static int MAX_LM = 3;

    User(String n, int id, float m) {
        this.name = n;
        this.StudentId = id;
        this.money = m;
        this.lm = new Landmark[User.MAX_LM];
    }

    void visits(Landmark l) {
        if(this.lmCounter < MAX_LM) {
            this.lm[this.lmCounter++] = l;
        } else {
            System.out.println("Please go home, you visited too many places already!\n");
        }
    }

    void searchStore() {
        //insert code here
    }

    void viewState() {
        System.out.println("\n======== VIEW STATE ========");
        System.out.println("Student ID: " + this.StudentId);
        System.out.println("Student Name: " + this.name);
        System.out.println("Student's Money: " + this.money);

        if(this.lmCounter == 0) {
            System.out.println(this.name + " is still in school!\n");
        } else {
            System.out.println(this.name + " visited :");
            for (int i = 0; i < lmCounter; i++) {
                Landmark L = lm[i];
                int j = i+1;
                System.out.println(j + ". " + L.name);
            }

        }
    }
}

```

**CANDYSTORE CLASS**

```
package testing;

public class CandyStore {
    String name;
    int StoreId;
    float cost; // cost of candies inside the store
    int sales;
    Landmark[] LM;
    int lmCounter;
    static int MAX_LM = 3;

    CandyStore(String n, int id, float c) {
        this.name = n;
        this.StoreId = id;
        this.cost = c;
        this.sales = 0;
        this.LM = new Landmark[CandyStore.MAX_LM];
    }

    void addLandmark(Landmark lm) {

        if(this.lmCounter < MAX_LM) {
            this.LM[this.lmCounter++] = lm;
        } else {
            System.out.println("Can't add landmark\n");
        }

    }

    void ViewState() {
        System.out.println("\n======== VIEW STATE ========");
        System.out.println("Store ID: " + this.StoreId);
        System.out.println("Store Name: " + this.name);
        System.out.println("Store Sales: " + this.sales);

        System.out.println("Landmark nearby");
        if(lmCounter == 0) {
            System.out.println("The store doesn't have any recognizable landmark\n");
        } else {
            for(int i = 0; i < lmCounter; i++) {
                Landmark l = LM[i];
                int j = i+1;
                System.out.println(j + ". " + l.name);
            }
        }
    }
}

```

**LANDMARK CLASS**

```
package testing;

public class Landmark {
    int LMid; // landmark number
    String name;

    Landmark (String n, int id) {
        this.name = n;
        this.LMid = id;
    }

    void viewState() {
        System.out.println("\n======== VIEW STATE ========");
        System.out.println("Landmark Number: " + this.LMid);
        System.out.println("Landmark Name: " + this.name);
    }
}

```

PS. Please show me how to do the code correctly, thank you.