1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
user100 [1]
3 years ago
9

Write a method that draws a circle and a square that is centered in a DrawingPanel. The method will take in the width and height

(they are the same for both the circle and square) and a Graphics object as parameters
IN java
current code: turn it into a method along with the main method
import java.awt.*;
public class Graphics {
static final int WIDTH = 300;
static final int HEIGHT = 200;
public static void drawGraphics () {
}
public static void main(String []args) {
DrawingPanel2 draw = new DrawingPanel2(WIDTH,HEIGHT); // Make a DrawginPanel2 of size 300 by 200.
Graphics2D g = draw.getGraphics(); // gets graphics from DrawingPanel so you can draw
g.setColor(Color.RED);
g.fillRect(45, 30, 200, 150);
g.setColor(Color.BLUE);
g.fillOval(70, 30, 150, 150);
}
}
Computers and Technology
1 answer:
Katarina [22]3 years ago
3 0

Answer:

public static void drawGraphics (Graphics g, int width, int height) {

   int r = Math.round(width/2);

   int x = 45;

   int y = 30;

     g.setColor(Color.RED);

   g.fillRect(x, y, width, height);

   g.setColor(Color.BLUE);

   g.fillOval(Math.round(x/2), Math.round(y/2), r, r);

}

Explanation:

The Java method "drawGraphics" of the Graphics class accepts draws a square with the "fillRect()" method of the Graphics class object and at its center, a circular path is drawn as well.

You might be interested in
Reverse Word Order: Write a program that reverses the order of the words in a given sentence. This program requires reversing th
Lerok [7]

Answer:

The program in C++ is as follows:

#include <bits/stdc++.h>

using namespace std;

int main(){

string sentence,word="";

getline (cin, sentence);

vector<string> for_reverse;

for (int i = 0; i < sentence.length(); i++){

 if (sentence[i] == ' ')  {

  for_reverse.push_back(word);

  word = "";  }

 else{    word += sentence[i];}  }

for_reverse.push_back(word);

sentence="";

for (int i = for_reverse.size() - 1; i > 0; i--){

 sentence+=for_reverse[i]+" ";}

sentence+=for_reverse[0];

cout<<sentence<<endl;

return 0;

}

Explanation:

This declares sentence and word as strings; word is then initialized to an empty string

string sentence,word="";

This gets input for sentence

getline (cin, sentence);

This creates a string vector to reverse the input sentence

vector<string> for_reverse;

This iterates through the sentence

for (int i = 0; i < sentence.length(); i++){

This pushes each word of the sentence to the vector when space is encountered

<em>  if (sentence[i] == ' ')  { </em>

<em>   for_reverse.push_back(word);</em>

Initialize word to empty string

  word = "";  }

If the encountered character is not a blank space, the character is added to the current word

<em>  else{    word += sentence[i];}  } </em>

This pushes the last word to the vector

for_reverse.push_back(word);  

This initializes sentence to an empty string

sentence="";

This iterates through the vector

for (int i = for_reverse.size() - 1; i > 0; i--){

This generates the reversed sentence

 sentence+=for_reverse[i]+" ";}

This adds the first word to the end of the sentence

sentence+=for_reverse[0];

Print the sentence

cout<<sentence<<endl;

8 0
3 years ago
Databases, authentication, and user accounts are all part of a website's ______________.
Varvara68 [4.7K]

Answer:

The answer is "Backend".

Explanation:

The Backend Development applies to just the webserver side when they concentrate mostly on how well the site functions. The website generally includes 3 sections consist of all this web design: a client, program, or server. The Backend user codes are the information provided by the database to both the web browser.

5 0
3 years ago
PLS FAST DONT EXPLAIN
Rzqust [24]

Answer:

</head>

Explanation:

8 0
3 years ago
A web based application that integrates html code with business logic is said to be in violation of what design principle?
adoni [48]

A web-based application that combines HTML code with business logic exists said to be in violation of Protection from variations design principle.

<h3>What is Html?</h3>

The Hypertext Markup Language or HTML stands for the standard markup language for documents developed to be displayed in a web browser. It can be administered by technologies such as Cascading Style Sheets and scripting languages such as JavaScript. HTML (Hypertext Markup Language) exists as the code that is used to structure a web page and its content. For example, content could be structured within a group of paragraphs, a list of bulleted points, or using photos and data tables

The protected variations pattern protects components from the variations on other elements (objects, systems, subsystems) by wrapping the direction of instability with an interface and operating polymorphism to make various implementations of this interface.

Hence, A web-based application that combines HTML code with business logic exists said to be in violation of Protection from variations design principle.

To learn more about Hypertext Markup Language refer to:

brainly.com/question/5560016

#SPJ4

5 0
2 years ago
Why does the media play such an important role in our personal freedom? Select 3 options.
Helga [31]

Answer:

It promotes self-expression

It holds the government accountable

It keeps us informed

Explanation:

I got them right Ed

7 0
2 years ago
Other questions:
  • A common chart type used to show the contributions of items to a whole is a _____ chart.
    6·1 answer
  • Using the College Registration example from Section 6.7.3 as a starting point, do the following:
    5·1 answer
  • What is used to determine when the communications channels are clear and when a device is free to transmit data
    6·1 answer
  • Does the cloud solution offer equal or greater data security capabilities than those pro-vided by your organization’s data cente
    14·1 answer
  • Hello I'm new to coding and in my class, we have jumped straight into coding with zero experience and or lessons, this is my fir
    14·1 answer
  • How long Will it take me to master scada and plc programming?​
    9·1 answer
  • PLZ HELP
    15·2 answers
  • Which king, after finding the decree of Cyrus giving the Jews permission to return and build the Temple, ordered the end of oppo
    11·2 answers
  • What do you think entertainment or gaming platforms will look like in the future?
    9·1 answer
  • Spam is _____.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!