Create a class diagram with generalization arrows (https://www.uml-diagrams.org) for the…
- User
Create a class diagram with generalization arrows (https://www.uml-diagrams.org) for the following real-world objects that all represent openings in walls. The class diagram shows the (hierarchical) relationships between these objects/classes: glass window, room entry, door, bull’s-eye, wall-break, wood door, sliding door, window, glass door explain me what we should do shortly ?
- Assistant
To create a class diagram with generalization arrows, you need to arrange the classes in a hierarchical structure, where more specific classes inherit from more general ones. Based on the given real-world objects, you can arrange the classes as follows:
- Create the classes as specified:
- glass window
- room entry
- door
- bull’s-eye
- wall-break
- wood door
- sliding door
- window
- glass door
- Arrange the classes in a hierarchical structure by adding generalization arrows:
- Start with the most general class "opening in wall" at the top.
- Add subclasses of the general class according to their hierarchical relationships. For example, "door", "window", and "bull's-eye" can be immediate subclasses of "opening in wall".
- Further subclassify the classes as necessary. For instance, "wood door", "sliding door", "glass door" can be subclasses of "door".
- "Bull's-eye" and "wall-break" remain as subclasses of "opening in wall".
The resulting class diagram should show the hierarchical relationships between the objects/classes representing the openings in walls, with appropriate generalization arrows indicating the inheritance relationships.
- User
Implement the class hierarchy from assignment 6.1 in JAVA. Define two variables and one method that each sub-class should inherit from the super-class. Add a comment to the method in sub-classes to specify how the implementation of the methods will change/deviate from the sub-class. (Please note: you just have to describe it and not implement it in detail). explain what should we do shortly
- Assistant
To implement the class hierarchy from assignment 6.1 in Java and define the necessary variables and methods, you can follow the given steps:
-
Create a superclass named "OpeningInWall" that contains two variables and one method that will be inherited by the subclasses.
-
Implement the superclass (OpeningInWall) by declaring the following variables and method:
- Variables: One variable for the name of the opening (e.g., "name") and another for the size of the opening (e.g., "size").
- Method: A method called "open()" that can be used to perform the action of opening the specific opening in the wall.
-
Create subclasses for specific opening types (e.g., GlassWindow, RoomEntry, Door, Bullseye, WallBreak, WoodDoor, SlidingDoor, Window, GlassDoor) and inherit from the superclass (OpeningInWall).
-
- User
Add a constructor to your BestBike class Component (assignments 5.4/4.2). The constructor should receive the instance variables component_ID, name, delivery_date, stock_amout, vendor and comment as parameters. You will realize that the main program now shows an error message. Make necessary adjustments in the Component class to fix the error (hint: add another constructor). explain the topic
- Assistant
In order to add a constructor to the
Componentclass from assignments 5.4/4.2, you need to follow these steps:-
Open the
Componentclass in your preferred Java IDE or text editor. -
Define a new constructor in the
Componentclass that takes the following parameters:component_ID,name,delivery_date,stock_amount,vendor, andcomment. -
Inside the constructor, assign the values of these parameters to the respective instance variables of the class. It can be done using the keyword to refer to the instance variables.
-
- User
Add another instance variable componentMaterial to your BestBike class Component from the previous assignment 6.3. Then add four final class variables/constants CARBON = 1 , ALU = 2, COMPOSITE = 3, STEEL = 4 to identify the main material that a component is made of. Add a new constructor to the class Component to account for the new constants. Instantiate the first component object in your main program with the new constructor and the following values (Please note: use the right class constant to set the value for material): Component ID: 1 Name: Frame Delivery Date: 20211111 Amount: 20 Vendor: Best Frames Ever Comment: good deal Material: 1 explain it shortly please
- Assistant
To add the
componentMaterialinstance variable and the four final class variables/constants to theComponentclass, you need to follow these steps:-
Open the
Componentclass in your preferred Java IDE or text editor. -
Add the
componentMaterialinstance variable to the class. For example:
private int componentMaterial;- Add the four final class variables/constants to identify the main material of a component:
public static final int CARBON = 1; public static final int ALU = 2; public static final int COMPOSITE = 3; public static final int STEEL = 4; -
- User
why we should create a method in the class door
- Assistant
Creating methods in the
Doorclass (which is a subclass ofOpeningInWall) allows you to define behavior specific to a door. Methods enable you to encapsulate functionality that can be performed on or by the door objects. Here are a few reasons why creating methods in theDoorclass is beneficial:-
: Methods allow you to encapsulate the behavior of a door within the class. By defining methods within the class, you can control access to the door's internals and ensure proper usage of its functionality.
-