Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
4th Edition
ISBN: 9780134787961
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 14, Problem 4AW
Write code that does the following: Instantiates the Ellipse class, and uses the constructor to draw an ellipse with its center located at (300, 200), an x-radius of 120 pixels, and a y-radius of 100. Then, set the ellipse’s stroke color to black, and the fill color to red.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Create the VisualCounter class, which supports both increment and decrement operations. Take the constructor's two arguments N and max, where N indicates the maximum operation number and max specifies the counter's maximum absolute value. Make a plot that displays the value of the counter each time its tally changes as a byproduct.
Step 1: Code in Java and name the java class file Artwork.javaStep 2: Have your JavaFx program set the Stage title to be your first and last name in the start method.Step 3: For this assignment, you are to create some simple JavaFx “generative art” Step 4: Your program must use one or more of the shape classes like Rectangle, Text, Circle, Arc, etc. (Refer to Javadoc page for ideas)Step 5: Your program must use one or more colors. (Refer to Javadoc page for ideas)Step 6: Your program must use java.util.Random to make the output change each time your program is run (for example, the colors, locations, and size of the shapes).Step 7: Describe the program and its behavior in a couple sentences.
Note: Make sure to include the used javafx import statements in the solution box.
Objectives:
1. To utilize the predefined methods found in the Graphics class under the
AWT package.
2. To demonstrate creativity in designing graphics for a certain class.
Activity:
Write a program that shows your own happy face character using the
different shapes found in the Graphics class. The program should ask for a
name and asks the user to choose from a list of at least 3 colors using
JOptionPane. The name will appear in the Graphics canvas on top or below
the character, while the color will be applied to the character's main face.
Required: There exists at least one or more of each of the following methods:
- drawOval()/fillOval()
- drawRect()/fillRect()
- drawPolygon()/fillPolygon()
- drawline()
- drawArc()/fillArc()
- setColor(new Color(R,G,B))
- setFont(new Font(type, style, size))
- drawstring()
Chapter 14 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Ch. 14.1 - Prob. 14.1CPCh. 14.1 - Prob. 14.2CPCh. 14.1 - Prob. 14.3CPCh. 14.1 - Prob. 14.4CPCh. 14.1 - In what package is the Color class?Ch. 14.1 - Prob. 14.6CPCh. 14.1 - Prob. 14.7CPCh. 14.1 - Prob. 14.8CPCh. 14.1 - Prob. 14.9CPCh. 14.1 - Prob. 14.10CP
Ch. 14.1 - Prob. 14.11CPCh. 14.1 - Prob. 14.12CPCh. 14.2 - Prob. 14.13CPCh. 14.2 - Prob. 14.14CPCh. 14.2 - Prob. 14.15CPCh. 14.2 - Prob. 14.16CPCh. 14.2 - Prob. 14.17CPCh. 14.2 - Prob. 14.18CPCh. 14.2 - Prob. 14.19CPCh. 14.2 - Prob. 14.20CPCh. 14.2 - Prob. 14.21CPCh. 14.3 - Prob. 14.22CPCh. 14.3 - Prob. 14.23CPCh. 14.3 - Prob. 14.24CPCh. 14.3 - Prob. 14.25CPCh. 14.3 - Prob. 14.26CPCh. 14.3 - Prob. 14.27CPCh. 14.3 - Prob. 14.28CPCh. 14.3 - Prob. 14.29CPCh. 14.3 - Prob. 14.30CPCh. 14.4 - What two classes do you use to play an audio file?Ch. 14.4 - Refer to your answer to Checkpoint 14.31. In what...Ch. 14.4 - Prob. 14.33CPCh. 14.4 - Prob. 14.34CPCh. 14.5 - What three classes do you use to play a video...Ch. 14.5 - Refer to your answer to Checkpoint 14.35. In what...Ch. 14.5 - Prob. 14.37CPCh. 14.6 - Prob. 14.38CPCh. 14.6 - Prob. 14.39CPCh. 14.6 - What type of event happens when the user presses...Ch. 14.6 - What KeyEvent method can you call to determine...Ch. 14.6 - Refer to your answer for Checkpoint 14.41. What...Ch. 14 - Line, Circle, and Rectangle are subclasses of...Ch. 14 - Prob. 2MCCh. 14 - Prob. 3MCCh. 14 - Prob. 4MCCh. 14 - Prob. 5MCCh. 14 - Prob. 6MCCh. 14 - Prob. 7MCCh. 14 - Prob. 8MCCh. 14 - This interpolator causes an animation to start...Ch. 14 - You use these two classes to play an audio file....Ch. 14 - Prob. 11TFCh. 14 - Prob. 12TFCh. 14 - True or False: If an ellipses X-radius and...Ch. 14 - Prob. 14TFCh. 14 - Prob. 15TFCh. 14 - Write a statement that instantiates the Line...Ch. 14 - Write a statement that instantiates the Circle...Ch. 14 - Prob. 3AWCh. 14 - Write code that does the following: Instantiates...Ch. 14 - Prob. 5AWCh. 14 - Write a statement that instantiates the Text...Ch. 14 - Prob. 7AWCh. 14 - Assume myBox is a Rectangle object. Write the code...Ch. 14 - Write code that creates a Circle, with a radius of...Ch. 14 - Prob. 10AWCh. 14 - Prob. 11AWCh. 14 - Prob. 1SACh. 14 - Prob. 2SACh. 14 - Prob. 3SACh. 14 - Prob. 4SACh. 14 - Prob. 5SACh. 14 - Prob. 6SACh. 14 - What RotateTransition class method do you use to...Ch. 14 - Prob. 8SACh. 14 - Prob. 9SACh. 14 - Prob. 10SACh. 14 - Prob. 11SACh. 14 - Prob. 1PCCh. 14 - Tree Age Counting the growth rings of a tree is a...Ch. 14 - Hollywood Star Make your own star on the Hollywood...Ch. 14 - Prob. 4PCCh. 14 - Solar System Use the Circle class to draw each of...Ch. 14 - Prob. 6PCCh. 14 - Prob. 7PCCh. 14 - Prob. 8PCCh. 14 - Coin Toss Write a program that simulates the...Ch. 14 - Lunar Lander The books online resources...Ch. 14 - Change for a Dollar Game The books online...Ch. 14 - Rock, Paper, Scissors Game Write a program that...
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
- .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.arrow_forwardHello I have the first part of my assignment done (creating the rectangle class, but I need to do this as well (PYTHON) Assignment due in 40 minutes Draw the UML diagram for the class, and then implement the class. Write a test program called TestRectangle that creates two Rectangle objects—one with width 4 and height 40 and the other with width 3.4 and height 35.7. Display the width, height, area, and perimeter of each rectangle in this order. here is my rectangle class: class Rectangle: def __init__(self, width = 1, heigth = 2): self._width = width self._height = heigth def getArea(self): return self._width*self._height def getPerimeter(self): return 2 * (self._height + self._width) if __name__ == "__main__": # Testing default values r1 = Rectangle() print("Area:",r1.getArea()) print("Perimeter:",r1.getPerimeter()) # Testing with values r2 = Rectangle(3, 4) print("Area:",r2.getArea())…arrow_forwardcreate an array of "Opinion" objects called "poll" that will represent five students opinions of a class.arrow_forward
- Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A, B, C, D, E" is correct. Each question has one correct answer. Thank you. Part 1 - Which method do you need to invoke to display a frame (or a "form")? A. displayWindow = true;B. setVisible = true;C. setVisible(true);D. setDisplay(true);E. setShowForm(true); Part 2 - Which sets the frame (or a "form") width to 100 pixels and the height to 200 pixels? A. setSize(100, 200);B. setSize(200, 100);C. setDims(100, 200);D. setDimensions(200, 100);E. setWidth(100); setHeight(100);arrow_forwardAVA code OVERVI EW This is a review exercise, so the primary goal of the exercise is to get your mind working and in the correct space.In this activity you will create a imaginary grid of locations that goes from −?≤?≤?, −?≤?≤?, with the coordinate (0,0) being "home". On this grid you will keep track of various animal objects as they move around the grid. Make sure that all animals stay within that grid at all timesincluding when they are created. Zwill be the map size and will control the highest number allowed on themap before wraping around. Using Java, create the following classes and primary program that uses the classes that you developed. INS T RUCT IONS Create the following classes. A N I MA L C LA SS Create an Animal class. Each animal has a name, an x and y integer coordinate. The Animal class should have at minimum the following methodsbelowbut you may want to add more if necessary: Also note, everyanimal will need to have to have “z”passed to it so that it knows how big the…arrow_forwardJava: Create the vehicle class UI transformation for the parking garage project as shown below: // Make sure the code is running with no errors • The parking lot has multiple levels. Each level has multiple rows of spots. • The parking lot can park motorcycles, cars, and buses. • The parking lot has motorcycle spots, compact spots, and large spots. • A motorcycle can park in any spot. • A car can park in either a single compact spot or a single large spot. • A bus can park in five large spots that are consecutive and within the same row. It cannot park in small spots. public enum VehicleSize { Motorcycle, Compact, Large } public abstract class Vehicle { protected ArrayList parkingSpots = new ArrayList(); protected String licensePlate; protected int spotsNeeded; protected VehicleSize size; public int getSpotsNeeded() { return spotsNeeded; } public VehicleSize getSize() { return size; } /* Park vehicle in this spot (among others, potentially) */ public void parkInSpot(ParkingSpot s) {…arrow_forward
- can you please do this in java eclipse idearrow_forwardOBAFGKM are the seven categories that are used to describe the absorption lines of a spectrum. Access the Spectral Types Color Slider by opening the Eclipsing Binary Stars section of the NAAP Labs Application and then the Spectral Types of Stars subsection (it is the last simulation on the page) and use it to complete the data table below. Spectral Type: include a letter and a number (no space). Temperature: Kelvin (K) is assumed for Temperature. Color: choose from Blue, White, Orange, or Red (spelling counts!).arrow_forwardFor this assignment, you are asked to create a ColorfulBouncingCircle class. ColorfulBouncingCircle should extend ColorfulCircle. Unlike the other Circle classes, it will include a velocity for the x and y axes. The constructor for ColorfulBouncingCircle includes these parameters:public ColorfulBouncingCircle(double radius, double centerX, double centerY, Color color, double xVelocity, double yVelocity) Note that we are treating x as increasing to the right and y as increasing down, as with Java’s graphics coordinates system. This was also seen with Circle’s draw method. ColorfulBouncingCircles will bounce around in a playing field which the tester will provide. The ColorfulBouncingCircle class should have a public static method to set the playing field width and height: public static void setPlayingFieldSize(double newWidth, double newHeight) ColorfulBouncingCircle will also include a method which should alter its centerX and centerY with each time tick (similar to a metronome’s…arrow_forward
- Please add a line(s) of code to the java code below. And comment the java code. Refer to image below and show output of the sierpenski triangle import java.awt.Color;import java.awt.Graphics;import javax.swing.JFrame; public class SierpinskiTriangle extends JFrame { public SierpinskiTriangle() { setTitle("Sierpinski Triangle"); setSize(1000,1000); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); } public void paint(Graphics g) { g.setColor(Color.BLUE); sierpinski(g, 500, 250, 500); } public void sierpinski(Graphics g, int x1, int y1, int side) { int x2 = x1 + side; int x3 = x1 + side / 2; int y2 = y1 - (int) (Math.sqrt(3.0) / 2.0 * side); int y3 = y1 + (int) (Math.sqrt(3.0) / 2.0 * side); if (side < 10) { g.drawLine(x1, y1, x2, y1); g.drawLine(x2, y1, x3, y2); g.drawLine(x3, y2, x1, y1); } else { sierpinski(g, x1, y1, side / 2);…arrow_forward.• 3. Rearrange these lines of code to construct a square, then another square that touches the first square and is situated to the right, then another square that touches the first square and is situated below. (Hint: Draw a picture.) Not all lines are useful. Press start to begin. 36 Start 37 Rectangle first = new Rectangle(5, 10, 20, 20); 38 new Rectangle(5, 25, 20, 20); Rectangle second = 40 ebook-bjeo-6-ch02-sec04-int1-5 5t.getX(), first.getY() + first.getHeight(), 20, 20); 40 new Rectangle(); 40 Rectangle first = new Square(5, 10, 20); Rectangle third = new Rectangle( first.getX() + first.getWidth(), first.getY(), 20, 20); 40 41 new Rectangle(25, 10, 20, 20); 44 38 /708 MacBook Air 37arrow_forwardDesign the wireframes and storyboard, interactivity diagram, object dictionary, and any necassary scripts for an interactive program for customers of Fortune's vacation Resort. Allow customers the option of choosing a studio, one bedroom, or two bedroom cabin, each of which costs a different weekly rental amount. Also allow the option of lake view, which increases the rental fee. The total fee is displayed when the user clicks a Reserve Cabin button.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Time Complexity Analysis - How To Calculate Running Time | InterviewBit; Author: InterviewBit;https://www.youtube.com/watch?v=--oxG4Q1PA0;License: Standard YouTube License, CC-BY