Java: Introduction to Problem Solving and Programming
7th Edition
ISBN: 9780133834604
Author: SAVITCH
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 7.6, Problem 33STQ
Program Plan Intro
“strokePolygon” method:
- This method is one method of “GraphicsContext”.
- User can draw any polygon using “strokePolygon” method.
- Syntax of this method is
Objectname_of_GraphicsContext.strokePolygon(Array_of_xValues, Array_of_yValues, number_of_points)
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
In JAVA, do not use Liang's BallPane Class. Just draw a circle.
Any and all help is appreciated, please also show the results with your code. Please see the attached image.
.In class DrawDemo, create a new method named -drawTriangle. This method should create a pen (as in the drawSquare method) and then draw a green triangle.
There needed to fix something in the above solution. Please repost the solution with these changes. Thank you!!
Use Bootstrap classes to make a circular image with a border around the image only.
Chapter 7 Solutions
Java: Introduction to Problem Solving and Programming
Ch. 7.1 - What output will be produced by the following...Ch. 7.1 - What output will be produced by the following...Ch. 7.1 - What output will be produced by the following...Ch. 7.1 - Consider the following array: int [] a = new...Ch. 7.1 - What is wrong with the following code to...Ch. 7.1 - Write a complete Java program that reads 20 values...Ch. 7.2 - Write some Java code that will declare an array...Ch. 7.2 - Rewrite the method displayResults of the program...Ch. 7.2 - What output will be produced by the following...Ch. 7.2 - Give the definition of a static method called...
Ch. 7.2 - Give the definition of a static method called...Ch. 7.2 - Prob. 12STQCh. 7.2 - The following method compiles and executes but...Ch. 7.2 - Suppose that we add the following method to the...Ch. 7.3 - Prob. 15STQCh. 7.3 - Replace the last loop in Listing 7.8 with a loop...Ch. 7.3 - Suppose a is an array of values of type double....Ch. 7.3 - Suppose a is an array of values of type double...Ch. 7.3 - Prob. 19STQCh. 7.3 - Consider the partially filled array a from...Ch. 7.3 - Repeat the previous question, but this time assume...Ch. 7.3 - Write an accessor method getEntryArray for the...Ch. 7.4 - Prob. 23STQCh. 7.4 - Write the invocation of the method selectionSort...Ch. 7.4 - How would you need to change the method...Ch. 7.4 - How would you need to change the method...Ch. 7.4 - Consider an array b of int values in which a value...Ch. 7.5 - What output is produced by the following code?...Ch. 7.5 - Revise the method showTable in Listing 7.13 so...Ch. 7.5 - Write code that will fill the following array a...Ch. 7.5 - Write a void method called display such that the...Ch. 7.6 - Prob. 33STQCh. 7 - Write a program in a class NumberAboveAverage that...Ch. 7 - Write a program in a class CountFamiles that...Ch. 7 - Write a program in a class CountPoor that counts...Ch. 7 - Write a program in a class FlowerCounter that...Ch. 7 - Write a program in a class characterFrequency that...Ch. 7 - Create a class Ledger that will record the sales...Ch. 7 - Define the following methods for the class Ledger,...Ch. 7 - Write a static method isStrictlyIncreasing (double...Ch. 7 - Write a static method removeDuplicates(Character[]...Ch. 7 - Write a static method remove {int v, int [] in}...Ch. 7 - Suppose that we are selling boxes of candy for a...Ch. 7 - Create a class polynomial that is used to evaluate...Ch. 7 - Write a method beyond LastEntry (position) for the...Ch. 7 - Revise the class OneWayNoRepeatsList, as given in...Ch. 7 - Write a static method for selection sort that will...Ch. 7 - Overload the method selectionSort in Listing 7.10...Ch. 7 - Revise the method selectionSort that appears in...Ch. 7 - Prob. 18ECh. 7 - Write a sequential search of an array of integers,...Ch. 7 - Write a static method findFigure (picture,...Ch. 7 - Write a static method blur (double [] [] picture)...Ch. 7 - Write a program that reads integers, one per line,...Ch. 7 - The following code creates a small phone book. An...Ch. 7 - Write the method rotateRight that takes an array...Ch. 7 - The following code creates a ragged 2D array. The...Ch. 7 - Write a program that will read a line of text that...Ch. 7 - Prob. 2PPCh. 7 - Add a method bubbleSort to the class ArraySorter,...Ch. 7 - Add a method insertionSort to the class...Ch. 7 - The class TimeBook in Listing 7.14 is not really...Ch. 7 - Define a class called TicTacToe. An object of type...Ch. 7 - Repeat Programming Project 10 from Chapter 5 but...Ch. 7 - Prob. 8PPCh. 7 - Write a GUI application that displays a picture of...Ch. 7 - ELIZA was a program written in 1966 that parodied...Ch. 7 - Prob. 11PPCh. 7 - Create a GUI application that draws the following...Ch. 7 - Practice Program 2 used two arrays to implement a...Ch. 7 - Practice Program 5.4 asked you to define Trivia...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Create a canvas. Using the canvas’s methods interactively, draw a red circle near the center of the canvas. Now draw a yellow rectangle.arrow_forwardAdd a JTextField and a JTextArea to the frame. Initialize the field to an empty string and the text area to “||”. Modify the program so that the contents of the field are appended to the area each time the user clicks the button. For example, if the user enters “xxx” in the field and clicks the button three times, the area contains “||xxx||xxx||xxx||”. Go off this code: import javax.swing.*;import java.awt.Color;import java.awt.event.*; public class MyCustomFrame extends JFrame{ // instance variables - replace the example below with your own private JButton button; private JLabel label; // add two more instance variables for JTextField and a JTextArea t // ... private static final int FRAME_WIDTH = 800; private static final int FRAME_HEIGHT = 800; public MyCustomFrame() { JPanel panel = new JPanel(); panel.setBackground(Color.RED); button = new JButton("Push Me"); // create a listener object and add it to the button //...…arrow_forwardImplement the "paint fill"feature seen in several picture editing products.To put it another way, if you have a screen (represented by a two-dimensional array of colours), a point, and a new colour, Fill in the surrounding area until the colour shifts away from the original.arrow_forward
- Open the clock-display project and create a ClockDisplay object by selecting the following constructor: new ClockDisplay() Call its getTime method to find out the initial time the clock has been set to. Can you work out why it starts at that particular time?arrow_forwardAssuming I have a Pixel, called px, write the code to change its contents to its greyscale equivalent.arrow_forwardWrite a program that displays a 3-by-3 square matrix. Each element in the matrix is a single digit between 1 and 9, randomly generated. This exercise covers the JavaFX topic and uses the GridPane method.arrow_forward
- Currently, there are two draw rectangle methods in the DoodleController class. Since two different turtles need to draw a rectangle, create a draw rectangle method in the DoodleTurtle class that will take the width and height of the rectangle as parameters and draw a rectangle of the specified size. The size will be the number of steps by the turtle. With the new method introduced, the calls to drawRectangleWithLittleTurtle and drawRectangleWithBigTurtle can be replaced with a call to the turtle’s drawRectangle method passing in the desired size of the rectangle. Refactor the DoodleController accordingly. Note: When you are done with the refactoring the drawRectangleWithLittleTurtle and drawRectangleWithBigTurtle method in the DoodleController need to be deleted. After this refactoring, do not move on until you verify the program works as it did before.arrow_forwardHow is it decided what image from the ImageList will be shown in the PictureBox, and what value is used to make that decision?arrow_forwardCreate new method in the Rectangle class called getArea to calculate the area of the rectangle. Call getArea method from the LengthWidthDemo class to print the area. In JAVA Programming pleasearrow_forward
- """An example of drawing and animation on a Canvas object""" from tkinter import * import time tk = Tk() Height = 300 Width = 400 tk.title('COMP3140-01 tkinter Demo') canvas = Canvas(tk, width=Width, height= Height) canvas.pack() ball=canvas.create_oval(0,100,50,50, fill='red') delta_x = 5 delta_y=0 var = StringVar() coord = Label(canvas, textvariable=var, fg='red') labelfont = ('times', 20, 'bold') coord.config(font=labelfont) canvas.create_window(180, 180, window=coord) #Add the coordinate label to the canvas while True: canvas.move(ball, delta_x, delta_y) #draw and move the ball object pos=canvas.coords(ball) #records the coordinates # Move the ball if pos[2] > Width: delta_x=-5 elif pos[0]<=0 : delta_x=5 var.set('( %d, %d )'%(pos[0],pos[1])) #update the coordinates tk.update() #update the whole frame time.sleep(0.03)arrow_forwardWithout adding any method or function to the classes shown below. Find out the coverage of the canvas that encloses all the circles that are generated by the program. Circle 0: center = (x = 35.57, y = -36.60), radius = 92.27Circle 1: center = (x = -18.04, y = -5.67), radius = 98.76Circle 2: center = (x = -10.82, y = -45.88), radius = 111.03Circle 3: center = (x = 48.97, y = 1.55), radius = 106.70Circle 4: center = (x = -12.89, y = 4.64), radius = 86.49Circle 5: center = (x = 19.07, y = 17.01), radius = 145.67Circle 6: center = (x = 15.98, y = 12.89), radius = 139.18Circle 7: center = (x = -3.61, y = -9.79), radius = 85.05Circle 8: center = (x = -8.76, y = 44.85), radius = 98.76Circle 9: center = (x = -39.69, y = -28.35), radius = 127.63Circle 1 intersecting with Circle 4, 5, 6Circle 3 intersecting with Circle 5Circle 4 intersecting with Circle 5, 6Circle 5 intersecting with Circle 6, 7, 8Circle 6 intersecting with Circle 7Circle 7 intersecting with Circle 9Bye... Note that…arrow_forwardhave to complete all the septs in green In this project, we will be using various features from the Qt framework to build a graphical user interface (UI) that contains a canvas (for drawing images) and buttons. You will receive different text files as input - each containing the elevation data for different mountains. Based on the dimensions and number of values in a file, you will create a canvas with similar dimensions. For example, a file that contains data for 256 rows and 256 columns, should have a canvas with dimensions of 256 x 256 data points (refer to the canvas on the right). heres the code import sys from PyQt5 import QtWidgets as qtw from PyQt5 import QtGui as qtg from PyQt5 import QtCore as qtc class mainWindow(qtw.QWidget): # Sprint-1 Step-1: Initializer function def __init__(self): super().__init__() # Sprint-1 Step-2: Variables self.n_rows = 0 self.n_columns = 0 self.grid_data = [] #…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT