Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write two public classes (named exactly), TextBox and TextBoxTester . TextBox contains the following overloaded static methods called textBoxString . This method returns a String

Write two public classes (named exactly), TextBox and TextBoxTester. TextBox contains the following overloaded static methods called textBoxString. This method returns a String value.

  • public static String textBoxString (int side)

The returned String value, when printed, displays a solid square of side characters. The character you use is up to you. Don't forget that ' ' will force a newline character into the returned String. For example, let's assume I want to use * as the character for my box:

  String s =  textBoxString(5); 
  System.out.println(s); 

will print

 ***** 
 ***** 
 ***** ***** *****
  • public static String textBoxString(int side, char bChar)

The returned String value, when printed, displays the outline of a square of side characters using bChar as the box character. For example,

  String s =  textBoxString(4, '+'); 
  System.out.println(s); 

will print

++++ + + + + ++++

  • public static String textBoxString(int rows, int cols)

The returned String value, when printed, displays the outline of a rectangle of rows rows and cols columns using your default box character.

  String s =  textBoxString(3, 4); 
  System.out.println(s); 

will print

**** * * ****

  • public static String textBoxString(int rows, int cols, char c1, char c2)

The returned String value, when printed, displays the outline of a rectangle of rows rows and cols columns using alternating c1 and c2 characters. Note that the first printed character should be c1, and every other printed character should be c1. The second printed character should be c2, and every other printed character should be c2. For example, in the example below, the end of the first line is 'x' and the beginning of the second line is 'o'. The next printed character, at the end of the second line is 'x'.

  String s =  textBoxString(3, 5, 'x', 'o'); 
  System.out.println(s); 

will print

xoxox o x oxoxo 

TextBoxTester has only a main method, and calls each of the textBoxString methods as a test.

Grading Elements

  • All overloaded methods are implemented in TextBox
  • The TextBox class has no main method
  • Each method has its correct signature
  • Each method returns its appropriate output
  • textBoxString methods do not themselves print anything. They only return a String that, when printed by the caller, prints the correct box
  • TextBoxTester has a main method and calls each TextBox.textBoxString method with appropriate parameter values

Java langage

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions

Question

=+and reduction in force, and intellectual property.

Answered: 1 week ago