public class Mall { private final int NUM_STORES = 2; private String name; Store
ID: 3739532 • Letter: P
Question
public class Mall {
private final int NUM_STORES = 2;
private String name;
Store[] storeList;
public Mall()
{
storeList = new Store[NUM_STORES];
}
//TODO 01: create a setter for name
//TODO 02: create a setter for a store in location i
//TODO 03: create a getter for a store in location i
//TODO 15: override toString to represent the mall as follows:
/*
* Mall Name:
* Store 1:
* Name:
* Type: (Grocery or Restaurant)
* Rating or itemList
* Store 2:
* Name:
* Type: (Grocery or Restaurant)
* Rating or itemList
*/
}
________________________________________
package cmps251.malls.stores;
public class Store {
private String title;
public Store(String title)
{
this.title = title;
}
public void setTitle(String title) {
this.title = title;
}
//TODO 04: create a setter for the title
}
Explanation / Answer
public class Mall { private final int NUM_STORES = 2; private String name; Store[] storeList; public Mall() { storeList = new Store[NUM_STORES]; } //TODO 01: create a setter for name public void setName(String name) { this.name = name; } //TODO 02: create a setter for a store in location i public void setStore(Store s, int ind) { this.storeList[ind] = s; } //TODO 03: create a getter for a store in location i public Store getStore(int ind) { return this.storeList[ind]; } //TODO 15: override toString to represent the mall as follows: public String toString() { String ans = ""; for (int i = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.