/* Trapezoids.java ** Java class that includes a collection of methods to produce character-based ** renderings of simple regular trapezoids, along with functional methods that ** determine the number of "foreground" and "background" characters printed in ** these renderings. ** ** CMPS 134 - Fall 2024 ** Author: P. M. J. and < STUDENT's NAME > ** Last Modified: September 24, 2024 ** Collaborated with: ... ** Known flaws: ... */ public class Trapezoids { /* Produces a character-based rendering of a regular narrow-top trapezoid ** of the given length and height. The figure itself is drawn using the ** given foreground character, with the given background character also ** rendered around the figure to form a box. ** Pre-Conditions: (topLength > 0) and (height > 0) */ public static void drawNarrowTopTrapezoid(int topLength, int height, char foreground, char background) { // S t u b b e d !!! } /* Produces a character-based rendering of a regular narrow-bottom trapezoid ** of the given length and height. The figure itself is drawn using the ** given foreground character, with the given background character also ** rendered around the figure to form a box. ** Pre-Conditions: (bottomLength > 0) and (height > 0) */ public static void drawNarrowBottomTrapezoid(int bottomLength, int height, char foreground, char background) { // S t u b b e d !!! } /* Returns the "foreground area" of a regular trapezoid of the given ** length and height. This measure is equal to the number of foreground ** characters used in rendering the figure itself (and applies to both ** narrow-top and narrow-bottom trapezoids). ** Pre-Conditions: (narrowLength > 0) and (height > 0) */ public static int foregroundAreaOfTrapezoid(int narrowLength, int height) { int result = 0; // S t u b b e d !!! return result; } /* Returns the "background area" of a regular trapezoid of the given ** length and height. This measure is equal to the number of background ** characters used in rendering the portion of the output within the box ** but outside the figure itself (and applies to both narrow-top and ** narrow-bottom trapezoids). ** Pre-Conditions: (narrowLength > 0) and (height > 0) */ public static int backgroundAreaOfTrapezoid(int narrowLength, int height) { int result = 0; // S t u b b e d !!! return result; } // " H e l p e r " M e t h o d s // ------------------------------- /* Returns the number of background characters to be printed on each ** side of the run of foreground characters on the given line when ** rendering a narrow-top trapezoid of the given height. ** Pre-Conditions: 1 <= lineNumber <= height */ public static int narrowTopBackgroundLength(int height, int lineNumber) { return (height - lineNumber); } /* Returns the number of background characters to be printed on each ** side of the run of foreground characters on the given line when ** rendering a narrow-bottom trapezoid. ** Pre-Conditions: (lineNumber >= 1) */ public static int narrowBottomBackgroundLength(int lineNumber) { // S t u b b e d !!! return 0; } /* Returns the number of foreground characters to be printed ** on the given line when rendering a narrow-top trapezoid of ** the given length. ** Pre-Conditions: (narrowLength > 0) and (lineNumber >= 1) */ public static int narrowTopForegroundLength(int narrowLength, int lineNumber) { // S t u b b e d !!! return 0; } /* Returns the number of foreground characters to be printed on ** the given line when rendering a narrow-bottom trapezoid of ** the given length and height. ** Pre-Conditions: (narrowLength > 0) and (0 < lineNumber <= height) */ public static int narrowBottomForegroundLength(int narrowLength, int height, int lineNumber) { // S t u b b e d !!! return 0; } /* Prints the given character the given number of times. This method ** appears in our course text, Building Java Programs 5e, on page 153. */ private static void writeChars(char ch, int number) { for (int i = 0; i < number; i++) { System.out.print(ch); } } }