Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Shiny Shoe Store Exercise Translate the class diagram and the pseudocode you wro

ID: 3604087 • Letter: S

Question

Shiny Shoe Store Exercise

Translate the class diagram and the pseudocode you wrote for the Shiny Shoe Store in Homework 2 into Java classes. Include the class diagram as one of the files you are submitting. The Shoe class should contain the following:

A default constructor that initializes each attribute to some reasonable default value for non-existent shoes.

Another constructor method that has a parameter for each data member. This constructor initializes each attribute to the value provided when an object of this type is instantiated.

Accessor and mutator methods for each attribute.

A method that displays all the data about the shoes. (10 points Extra Credit if this is implemented using a toString() method.)

The application class should contain main() which does the following:

Instantiate two objects of the Shoes class. The first object should be named nerdShoes and use the default constructor. The second object should be named coolShoes and use the second constructor to initialize the style to “sandals”, the color to “brown”, and the size to 8.5.

Set the color of the nerdShoes to “tan”.

Set the style of the nerdShoes to “walking”.

Set the size of the nerdShoes to 9.5.

Display the style of the nerdShoes, using the appropriate method call.

Change the color of the coolShoes to “purple”.

Display the style of the coolShoes, using the appropriate method call.

Call the coolShoes object’s method that displays all the information about the shoes.

Explanation / Answer

public class Shoe {

private String color;
private float size;
private String style;

//Default constructor  
public Shoe() {
this.color = "Black";
this.size = 8.0f;

this.style = "Walking";
}

//parameterized constructor

public Shoe(String color, float size, String style) {
this.color = color;
this.size = size;

this.style = style;
}

  
//Accesor and Mutator method
public String getColor() {
return color;
}

public void setColor(String color) {
this.color = color;
}

public float getSize() {
return size;
}

public void setSize(float size) {
this.size = size;
}

public String getStyle() {
return style;
}

public void setStyle(String style) {
this.style = style;
}

//display all the data about shoe using toString.

public void display(Shoe obj) {
System.out.println("Shoe data = "+obj.toString());
}



public void displayShoeStyle() {
System.out.println(this.getStyle());
}

//Main method
public static void main (String str[]) {

//nerdShoe example   

Shoe nerdShoes = new Shoe();
nerdShoes.setColor("Tan");
nerdShoes.setStyle("Walking");
nerdShoes.setSize(9.5f);
System.out.println("Properties of neard shoe given below");
nerdShoes.display(nerdShoes);
nerdShoes.displayShoeStyle();



//cool shoe example
Shoe coolShoes = new Shoe("Brown", 8.5f, "Sandle");
coolShoes.display(coolShoes);
coolShoes.setColor("Purple");
coolShoes.displayShoeStyle();
coolShoes.display(coolShoes);
}

@Override
public String toString() {
return "Shoe{" + "color=" + color + ", size=" + size + ", style=" + style + '}';
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote