Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Jacobb Coates
- // Lab 4
- // February 11th, 2022
- import java.awt.Color;
- public class Cylinder extends Circle {
- private int length;
- public Cylinder(int radius, int length, Color color) {
- super(radius, length, color);
- this.length = length;
- this.radius = radius;
- }
- public Cylinder(int newX, int newY, int newRadius, int newLength) {
- super(newX, newY, newRadius);
- length = newLength;
- }
- public int getLength() {
- return length;
- }
- public void setLength(int length) {
- this.length = length;
- }
- public int calcArea() {
- return (int) Math.ceil( 2 * 3.14 * radius * radius + 2 * 3.14 * radius * length);
- }
- public int calcVolume() {
- return (int) Math.ceil(3.14 * radius * radius * length);
- }
- public DrawFigure drawFigure() {
- DrawFigure cylinder1 = new DrawFigure(4, getRadius(), length);
- return cylinder1;
- }
- public String toString() {
- return "Length = " + length + " " + super.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement