Question

In: Computer Science

Draw a UML diagram that describes a class that will be used to describe a product...

Draw a UML diagram that describes a class that will be used to describe a product for sale on Glamazon.com. The product has a name, a description, a price, ratings by many customers (1 to 5 stars), and a group of customer comments. New products have no ratings or comments by customers, but do have a name, description and price. The price can be changed and more customer ratings and comments can be added. A global average rating of all customer ratings also needs to be provided. All other fields are unchangeable. Show at least one constructor.

Hint: The easiest way to draw UML diagrams in a Word document is to use a one column by 3 row table.

Solutions

Expert Solution

The UML diagram for the class Product is shown as follows:

The name of the class is Product which is shown in the first row of the diagram. The Product class will have 5 member variables which are shown as follows:

·       pname: The variable pname will have the name of the product and it cannot be changed. The data type of this variable will be string of constant type because it is unchangeable.

·       price: The variable price will be used to store the price of the product. The datatype of this variable will be float.

·       desc: The variable desc is used to store the description of the product and its datatype is string of constant type because it is unchangeable.

·       rating[]: The array rating is used to store the rating of customers between 1 and 5. This rating can be changed by any method. The return type of this variable will be integer.

·       comments[]: The variable comments is used to store the comments of the customers. This is an array of string type and can be changed by any other method.

The class Product will have 5 member functions which are as follows:

·       Product(name, price, description, rating, comments): It is a parameterized constructor and used to initialize the values of 5 member variables.

·       Product(name, price, description): It is another parameterized constructor which is used to initialize the values of 3 member variables.

·       addProduct(): This function is used to add a new product except those added by constructor. It return 1, if a new product is added, otherwise, 0.

·       isNewProduct(flag): This function is used to check whether the product is new or old. If the value of flag is 1, then it means a new product is added and this function returns true.

·       avgGlobalRating(rating): This function is used to calculate and return the average global rating of all the ratings given by customers.

·       dispProductInfo(): This function is used to show the details of each product.


Related Solutions

draw a uml diagram for a class
draw a uml diagram for a class
Draw a UML diagram for the classes. Code for UML: // Date.java public class Date {...
Draw a UML diagram for the classes. Code for UML: // Date.java public class Date {       public int month;    public int day;    public int year;    public Date(int month, int day, int year) {    this.month = month;    this.day = day;    this.year = year;    }       public Date() {    this.month = 0;    this.day = 0;    this.year = 0;    } } //end of Date.java // Name.java public class Name...
create the UML Diagram to model a Movie/TV viewing site. Draw a complete UML class diagram...
create the UML Diagram to model a Movie/TV viewing site. Draw a complete UML class diagram which shows: Classes (Only the ones listed in bold below) Attributes in classes (remember to indicate privacy level, and type) No need to write methods Relationships between classes (has is, is a, ...) Use a program like Lucid Cart and then upload your diagram. Each movie has: name, description, length, list of actors, list of prequals and sequals Each TV Show has: name, description,...
A UML class diagram can be used to model UML by considering each graphical component of...
A UML class diagram can be used to model UML by considering each graphical component of the notation to be a class. For example, a class diagram contains a collection of classes. Your problem is to construct and draw one class diagram with the below UML elements. That is, there will be a class for each of the elements listed. You must also provide ALL of the relationships between each of these classes. The elements to model in the class...
1. draw a UML diagram that describes the Tablet Store's purchases and payment process. 2. using...
1. draw a UML diagram that describes the Tablet Store's purchases and payment process. 2. using microsoft access implement a relational database from your UML class diagram. Identify at least three fields per table. 3. describe how you would use the relational database to determine the Tablet store's account payable
(Using Date Class) The following UML Class Diagram describes the java Date class: java.util.Date +Date() +Date(elapseTime:...
(Using Date Class) The following UML Class Diagram describes the java Date class: java.util.Date +Date() +Date(elapseTime: long) +toString(): String +getTime(): long +setTime(elapseTime: long): void Constructs a Date object for the current time. Constructs a Date object for a given time in milliseconds elapsed since January 1, 1970, GMT. Returns a string representing the date and time. Returns the number of milliseconds since January 1, 1970, GMT. Sets a new elapse time in the object. The + sign indicates public modifer...
(Using Random Class) The following UML Class Diagram describes the java Random class: java.util.Random +Random() +Random(seed:...
(Using Random Class) The following UML Class Diagram describes the java Random class: java.util.Random +Random() +Random(seed: long) +nextInt(): int +nextInt(n: int): int +nextLong(): long +nextDouble(): double +nextFloat(): float +nextBoolean(): boolean Constructs a Random object with the current time as its seed. Constructs a Random object with a specified seed. Returns a random int value. Returns a random int value between 0 and n (exclusive). Returns a random long value. Returns a random double value between 0.0 and 1.0 (exclusive). Returns...
In Java Design a Triangle class (Triangle.java) that extends GeometricObject. Draw the UML diagram for both...
In Java Design a Triangle class (Triangle.java) that extends GeometricObject. Draw the UML diagram for both classes and implement Triangle. The Triangle class contains: ▪ Three double data fields named side1, side2, and side3 with default values 1.0 to denote three sides of the triangle. ▪ A no-arg constructor that creates a default triangle. ▪ A constructor that creates a triangle with the specified side1, side2, side3, color, and filled arguments. ▪ The accessor methods for all three data fields....
Draw UML diagram Define a class named Document that contains a member variable of type string...
Draw UML diagram Define a class named Document that contains a member variable of type string named text that stores any textual content for the document. Create a function named getText that returns the text field and a way to set this value. Next, define a class for Email that is derived from Document and that includes member variables for the sender , recipient , and title of an e-mail message. Implement appropriate accessor and mutator functions. The body of...
Use the UML tool to draw a UML class diagrambased on the descriptions provided below....
Use the UML tool to draw a UML class diagrambased on the descriptions provided below.The diagram should be drawn with a UML toolIt should include all the classes listed below and use appropriate arrows to identify the class relationshipsEach class should include all the described attributes and operations but nothing elseEach constructor and method should include the described parameters and return types - no more and no lessPlease do one of the following in JavaDescriptions of a PriceBecause of the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT