Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Malbin {
- //Create Constractor with Length And Width !
- private double length,width;
- // GETTERS and SETTERS !
- 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 Malbin(double length, double width) {
- this.length = length;
- this.width = width;
- }
- // Constractor that takes 10,10 !
- public Malbin() {
- this(10, 10);
- }
- // Calculate the sides of the malbin 2*length + 2*width !
- public void Sides() {
- double sidesLength = 2 * (length) + 2 * (width);
- System.out.printf("The Malbin sideS length is: " + sidesLength);
- }
- //Calculate malbin surface = length * width = surface !
- public void malbinSurface() {
- double size = length * width;
- System.out.print("Malbin Scale size is: " + size);
- }
- // print malbin with "*" ****
- // ****
- // ****
- public void print() {
- for (int mLength = 0; mLength < length; mLength++) {
- for (int mWidth = 0; mWidth < width; mWidth++) {
- System.out.print("*");
- }
- System.out.println();
- }
- }
- // print malbin the same thing but with Character !
- public void print2(char character) {
- for (int mLength = 0; mLength < length; mLength++) {
- for (int mWidth = 0; mWidth < width; mWidth++) {
- System.out.print(character);
- }
- System.out.println();
- }
- }
- }
- ***************************************************************************************************************************************
- public class MalbinTester {
- public static void main(String[] args) {
- // send to functions and Printing !
- Malbin m1 = new Malbin();
- m1.Sides();
- System.out.println();
- m1.malbinSurface();
- System.out.println();
- m1.print();
- System.out.println();
- m1.print2('x');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement