Reference no: EM132337597
Question
Does my java code correct and follow all of the criteria? Could you include a class diagram for reference as well. (mine has errors)
If anything is wrong please let me know what I am missing and how i can fix it, Thanks!
The Dress Barn Company sells different dresses, such as spring and winter dresses. Each style of dress is offered in different colors, such as blue and red. Available dress sizes range from 0 to 14. Design an object-oriented computer program by doing the following:
Create the Java for the dress class that contains the style of the dress, the color of the dress, and the size. Examples of valid values for the style are "lace" and "sweater". Examples of valid values for the color are "blue" and "black". Examples of valid values for the size are 0 and 8. Be sure to choose the most appropriate data type for the attributes. For this class definition, include the following:
A default constructor that initializes each attribute to some reasonable default value for the dresses.
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 dresses.
Add a class diagram for the application to the one you created for part a above, add the correct relationship and multiplicity, and insert the completed diagram immediately before the pseudocode for this problem in the Word document.
b. Creat a main application
Write the Javafor the application program for the coat store with a main() module that instantiates two objects of the Dress class.
The first object should be named winterDress and use the default constructor. 2. The second object should be named springDress and use the second constructor to initialize the style to "lace", the color to "green", and the size to 12. Include the following instructions in the main() method, in the order specified below
A call to set the color of the winterDress to "yellow".
A call to set the style of the winterDress" to "sweater".
A call to set the size of the winterDress to 6.
A Statement that displays the style of the springDress, using the appropriate method call.
A call to change the color of the winterDress to "green".
A statement that displays the style of the winterDress, using the appropriate method call.
A call for the winterDress object to the method that displays all the information about the dress.
class Dress{
//Attributes
private String style;
private String color;
private int size;
//constuctor
public Dress(){
style="";
color="";
size=0;
}
public Dress(String newStyle,String newColor,int newSize){
style=newStyle;
color=newColor;
size=newSize;
}
//Getters
public String getStyle(){
return style;
}
public String getColor(){
return color;
}
public int getSize(){
return size;
}
//Setters
public void setStyle(String newStyle){
style=newStyle;
}
public void setColor(String newColor){
color=newColor;
}
public void setSize(int newSize){
if(newSize>0){
size=newSize;
}
else{
System.out.println(newSize+" is invalid size.");
size=0;
}
}
//to string method
public String toString(){
return style+" dress, Color of the dress: "+color+", Size of the dress: "+size;
}
}
DressProgram.java
class DressProgram{
public static void main(String[] args){
//1. The first object should be named winterDress and use the default constructor.
Dress winterDress=new Dress();
//2. The second object should be named springDress and use the second constructor to initialize the style to "lace", the color to "green", and the size to 12
Dress springDress=new Dress("lace","green",12);
//A call to set the color of the winterDress to "yellow".
winterDress.setColor("Yellow");
// A call to set the style of the winterDress to "sweater".
winterDress.setStyle("sweater");
// A call to set the size of the winterDress to 6.
winterDress.setSize(6);
// A Statement that displays the style of the springDress, using the appropriate method call.
System.out.println(springDress.getStyle()+" dress");
//A call to change the color of the winterDress to "green".
winterDress.setColor("green");
// A statement that displays the style of the winterDress, using the appropriate method call.
System.out.println(winterDress.getStyle()+" dress");
//A call for the winterDress object to the method that displays all the information about the dress.
System.out.println(winterDress);
}
}