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 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,...
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...
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...
Draw the diagram (ER / MR / UML) for a database containing the following characteristics: •...
Draw the diagram (ER / MR / UML) for a database containing the following characteristics: • Presence sensor that stores presence information with its timestamp and its location. • Distance sensor that saves distance information with its timestamp and its location. • An actuator of a switch that energizes a bulb, where the record of its been with your timestamp and your location. • An actuator of a motor that opens a door, where the record of its been with...
Complete the following class UML design class diagram by filling in all the sections based on...
Complete the following class UML design class diagram by filling in all the sections based on the information given below.         The class name is Boat, and it is a concrete entity class. All three attributes are private strings with initial null values. The attribute boat identifier has the property of “key.” The other attributes are the manufacturer of the boat and the model of the boat. Provide at least two methods for this class. Class Name: Attribute Names: Method...
What would the pseudocode look like for this UML class diagram? Class - oranges: String -...
What would the pseudocode look like for this UML class diagram? Class - oranges: String - bananas: String - grapes: String - apples: String + Class(String bananas, String grapes, String apples) + oranges( ): void + isValidGrapes( ): boolean + isValidApples( ): boolean + getOranges( ): String + getBananas( ): String + setBananas(String bananas): void + getGrapes( ): String + setGrapes(String grapes): void + getApples( ): String + setApples(String apples): void
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT