current position:Home>Is a graphic inheritance problem
Is a graphic inheritance problem
2022-02-02 19:47:09 【CSDN Q & A】
1) Writing graphics classes Geom, Have private properties : Color and whether to fill , Define common construction methods 、 Get each
The method of multiple attributes and the method of obtaining graphic information :
(2) Write a rectangular class that inherits the graphic class Rectangle, Have private properties : Length and width , Define common construction methods 、
The method of obtaining each attribute and the method of calculating the area :
(3) Write a box class that inherits the rectangle class Rectlinder, There are private properties : high , Define common construction methods 、 a
The method of taking attributes and the method of finding volume , Method of rewriting graphic information .
(4 Design an entry main class , Construct several cubes , List their data and behavior
Define the class according to the class diagram , And then create the object , Call the member method of the class . The design of specific classes is as follows :
Refer to the answer 1:
This is not translating words into code ? Come on as required That's it
Refer to the answer 2:
Refer to the answer 3:
/** * 1) Writing graphics classes Geom, Have private properties : Color and whether to fill , Define common construction methods 、 Get each * The method of multiple attributes and the method of obtaining graphic information : */public class Geom { private String color; private String filling; public Geom(String color, String filling) { this.color = color; this.filling = filling; } public String getColor() { return color; } public void setColor(String color) { this.color = color; } public String getFilling() { return filling; } public void setFilling(String filling) { this.filling = filling; } @Override public String toString() { return "Geom{" + "color='" + color + '\'' + ", filling='" + filling + '\'' + '}'; }}
Refer to the answer 4:
Refer to the answer 5:
package entity;/** * (3) Write a box class that inherits the rectangle class Rectlinder, There are private properties : high , Define common construction methods 、 a * The method of taking attributes and the method of finding volume , Method of rewriting graphic information . */public class Rectlinder extends Rectangle{ private Double height; public Rectlinder(Double length, Double width, Double height) { super(length, width); this.height = height; } public Double getHeight() { return height; } public void setHeight(Double height) { this.height = height; } public Double getVolume(Double length, Double width, Double height){ return length * width * height; } @Override public String toString() { return "Rectlinder{" + "length=" + super.getLength() + "width=" + super.getWidth() + "height=" + height + '}'; }}
Refer to the answer 6:
Refer to the answer 7:
package entity;/** * (2) Write a rectangular class that inherits the graphic class Rectangle, Have private properties : Length and width , Define common construction methods 、 * The method of obtaining each attribute and the method of calculating the area : */public class Rectangle { private Double length; private Double width; public Rectangle(Double length, Double width) { this.length = length; this.width = width; } public Double getLength() { return length; } public void setLength(Double length) { this.length = length; } public Double getWidth() { return width; } public void setWidth(Double width) { this.width = width; } public Double getArea(Double length, Double width){ return length * width; }}
Refer to the answer 8:
copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202021947069883.html
The sidebar is recommended
- C language file encryption applet problem
- Three types of MPEG images
- How to write this program code
- Questions about data structure: data structure sequence table (language-c language)
- A problem of energy economics
- Vscode why does Python have two problems when the external window is running? Press any key to continue?
- Using 7474n to build JK Trigger and D trigger.
- C language two-dimensional array, for interpretation
- When simulating with botu and factory IO, factory IO I2 The contacts behind 0 are not working
- How to solve termux qqbot error?
guess what you like
-
C + + getline cannot correctly read the console input Chinese
-
Android development bookkeeping
-
About the problem of C language: input 12 + 3 with DEVC + + to get 12.000000. I don't know what's wrong, include & lt; stdio. h>
-
Prompt the user to enter an integer n and N real numbers, calculate and output the sum of the negative numbers in the input n real numbers.
-
Using C52 and LCD1602 to simulate an electronic clock, how to program four modes and one LED flashing for four keys
-
Do any friends know how to do this? Please
-
For problems occurred during GCN reproduction, it is suggested that the openposedemo file cannot be found
-
TypeError: string indices must be integers
-
I really can't find answers to the exercises after freshman class.
-
How is the MSE value compared with the vector?
Random recommended
- How to set a draw when making tic tac toe chess in Python
- Solving Python language C language
- How does Maple set a variable to be any integer from a certain interval
- How to realize that the opening of a website computer is one interface and the opening of a mobile phone is another interface, similar to self adaptation?
- After entering two indefinite length arrays and sorting them, merge and sort the two arrays again
- The computer has a web, but it can't access other web pages except the navigation page display
- C + + how to do this program
- Want to know how to find the parameters of this function? How should the matlab code knock
- Multi module project cannot inject mapper java
- MapReduce average score how to find the average of each line
- Wechat applet rendering layer error
- What does this mean? Why can't I open my QQ
- CMD run Py file encountered a problem
- Help me see what's wrong
- Why not 13bingo
- Decipher the password and there is no result after running?
- Ask you why this code can't run (◞‸◟)
- Hello, can you extract the of our applet
- Why not show folders when attaching a database
- How can the last line end with 0 without spaces
- Generate images from HTML pages and download them into PDF files
- Two Python experiment questions
- Hidden display problems in HTML
- Is there any good analysis process for push box problem
- What's going on here?.,!
- Cyclic input and output. If the input is a number, it will print. If the input is not a number, it will print No
- C language freshman PTA input an English sentence, change the first letter of each word into capital letters.
- Question e: snake walking, please help me
- Why is the attenuation of wave height in numerical simulation serious?
- Difference between digital image processing and image signal processing (ISP)
- Oracle a column of multi value update problem.
- Write a program in Python.
- How can Python write here to become a variable
- Which rstudio is installed in win7 64 bit? Dear friends, the previous connection can install w10,8,7, but now it can only install W10. Cry.
- Which is better, CCD camera tracking or gray sensor tracking
- Virtual reality combined with AR space
- How to click two label controls in QT to subtract the customized numbers in the control
- Ask you why there is a period of garbled code in front of the output?
- QR code generation of shopping scanning payment and third-party payment
- The Internet is a large network composed of many small networks. Can a local area network also be such a small network? What's more, how large is the coverage of a small network in a large network?