Partners This is an individual assignment, though collaboration (not solution sharing is allowed. Problem Statement Back to skiing this week. You are going to build a program that manages ski ratings for a store. To do this, you need two classes. The Ski class will represent a ski and the Store class (partially provided) will represent a ski store. Customers will have the capability of rating a ski by giving it some integer number of stars. Suppose for some ski, one customer gave it 5 tars, another gave it 4 stars, and the final customer also gave it 4 stars, that ski would then have an average rating of 4.33 stars (don\'t worry about the number of digits after the decimal point) Your Ski class will have a variable for the ski\'s name and whatever data you need to track to determine the average \"number of stars\" it earned. You will also need a method called addCustReview in the Ski class that will take an integer parameter representing the number of stars the customer wishes to award that ski. After numerous customers review the ski, you will have the data you need to calculate the average rating, as demonstrated above Assignment Create a project called Inlab4 Copy this code into a class called Store and review it so you see what is going on. Create a class called Ski, where the only input parameter to the constructor is the name of the Ski. Create a method in the Ski class called addCustReview that will take the number of stars awarded for one customer review as the input parameter. Create a method in the Ski class called printStats that will print out the name of the ski, its average rating, and the total number of reviews it received Complete the getAvgRating method in the Store class so that it gives the average rating of skis in the store as the total number of stars awarded for all skis in the store divided by the total number of reviews given for all skis in the store. Note: This is not the average of the average ski ratings. Draw out an example if you don\'t see the distinction. Finally, build a Driver that creates two Ski instances, adds some customer reviews, creates a store with those two skis, then calls print Stats on the store. Make sure the output is correct. Your output will vary depending on your formatting and specific reviews, but as a guide. here is my output
public class Sky {
String skyname;
int review;
int rating;
Sky(){
}
Sky(String skyname){
setskyname(skyname);
}
public void setskyname(String skyname) {
// TODO Auto-generated method stub
this.skyname=skyname;
}
public String getskyname(){
return skyname;
}
public void addcustreview(int review,int rating){
this.review=review;
this.rating=rating;
}
public void printstate(){
System.out.println(\"name is:\"+skyname+\"review is:\"+review+\" and rating is\"+rating);
}
}
class Store
{
private String name;
public Sky s1;
public Sky s2;
public Store(String inName, Sky in1, Sky in2)
{
name = inName;
s1 = in1;
s2 = in2;
}
public double getAvgRating(){
double avgrating=0.0f;
avgrating=(s1.rating+s2.rating)/(s1.review+s2.review);
return avgrating;
}
public void printStats()
{
System.out.println(name + \":\");
System.out.println(\" Average Ski Rating: \" + getAvgRating());
System.out.println(\" Skis:\");
s1.printstate();
s2.printstate();
}
}
mainclass
public class driver
{
public static void main(String args[])
{
Sky s1=new Sky(\"clus\");
s1.addcustreview(1, 5);
Sky s2=new Sky(\"plnes\");
s2.addcustreview(1, 4);
Store s=new Store(\"galaxy\",s1,s2);
s.getAvgRating();
s.printStats();
}
}
output:
galaxy:
Average Ski Rating: 4.0
Skis:
name is:clusreview is:1 and rating is5
name is:plnesreview is:1 and rating is4