Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
2.1 kB
2
Indexable
Never
package ru.vsu.cs.vvp2021;

import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

            System.out.printf("----------------%n");
            sample(7,7);
        }




    public static void sample(int w, int h) {
        PrintStream out = System.out;
        for (int r = 0; r < h; r++) {
            if (r == 0 || r == h - 1) {
                out.print("*");
                for (int c = 1; c < w - 1; c++) {
                    out.print("-");
                }
                out.println("*");
            } else {
                out.print("|");
                for (int i = 0; i < h; i++) {
                    if (i == 0 || i == h - 2) {
                        out.print("*");
                        for (int c = 1; c < w - 3; c++) {
                            out.print("-");
                        }
                        out.print("*");
                        out.println("|");
                    } else {
                        out.print("|");
                        out.print("|");
                        for (int a = 0; a < h; a++) {
                            if (a == 0 || a == h - 3) {
                                out.print("*");
                                for (int c = 1; c < w - 5; c++) {
                                    out.print("-");
                                }
                                out.print("*");
                                out.print("|");
                                out.println("|");
                            } else {
                                out.print("|");
                                out.print("|");
                                out.print("|");
                                out.print("*");
                                out.print("|");
                                out.print("|");
                                out.println("|");
                            }
                        }
                    }
                }
            }
        }
    }
}