Question
Advanced Java Programming with Object-Oriented Programming Design VERY IMPORTANT NOTE!!: This program for the question below MUST USE at least 2 CLASSES, getters/setters, etc and
Advanced Java Programming with Object-Oriented Programming Design
VERY IMPORTANT NOTE!!: This program for the question below MUST USE at least 2 CLASSES, getters/setters, etc and other object-oriented design (OOD) concepts because I'm in a more advanced Java class that requires me to utilize the concepts mentioned above. Also, I need detailed, but brief comments to most, if not all of the code to explain what is being used in the code and what is does so I have a better understanding of the code. I've seen answers to the question below already posted, however they don't utilize object-oriented design (OOD) concepts such as a minumum of two classes, getters/setters, etc which is required for this advanced Java programming class. So please......answer the question and meet the requirements for this question. Basically, I need advanced Java object-oriented design concepts for simple programs so here's to hoping this works out and if it does, I'll give a thumbs up, I promise!!!
Modify the method created in Exercise 6.18 to receive a second parameter of type char called fillCharacter. Form the square using the char provided as an argument. Thus, if side is 5 and fillCharacter is # , the method should display
#####
#####
#####
#####
#####
Use the following statement (in which input is a Scanner object) to read a character from the user at the keyboard:
char fill = input.next().charAt( 0 );
Here's what I got to modify:
import java.util.Scanner; public class Asterisks { //Declarations private int side; //Getter public int getSide() {
return side;
} //Setter public void setSide(int side) {
this.side = side;
}
public Asterisks (int side) {
this.side = side;
} //Show the square public void displaySquare() {
for(int m=0;m System.out.println(); for(int k=0;k System.out.print("*"); } } } } class AsterisksMain { //Class with a main which will allow you to run this program. public static void main(String args[]) { Scanner sc = new Scanner(System.in); int side; System.out.println("Please Enter side of the square to be printed"); side = sc.nextInt(); while(side < 0) { //This happens if you enter something like "-1". System.out.println("You have entered negative value. Enter side again!!"); side = sc.nextInt(); } Asterisks as = new Asterisks(side); as.displaySquare(); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started