Tree Age
Counting the growth rings of a tree is a good way to tell the age of a tree. Each growth ring counts as one year. Use either the Circle or Ellipse classes to draw how the growth rings of a 5-year-old tree might look. Then, using the Text shape class, number each growth ring starting from the center and working outward with the age in years associated with that ring.
Want to see the full answer?
Check out a sample textbook solutionChapter 14 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Starting Out with Programming Logic and Design (4th Edition)
Computer Science: An Overview (12th Edition)
C Programming Language
Problem Solving with C++ (9th Edition)
Concepts of Programming Languages (11th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- Given the Solid class, extend it with: Pyramid Cylinder RectangularPrism Sphere Make sure to create the constructor and override the volume and surfaceArea methods. Also extend RectangularPrism with Cube. HINT: You can look up formulas for how to compute the volume and surface area of a certain type of shape online. ========================================== public class SolidTester{public static void main(String[] args){String name;double volume;double surfaceArea; // Pyramid constructor should take name, length, width, height// in that orderPyramid pyramid = new Pyramid("My pyramid", 1, 3, 5);name = pyramid.getName();volume = round(pyramid.volume(), 2);surfaceArea = round(pyramid.surfaceArea(), 2);System.out.println("Pyramid '" + name + "' has volume: " + volume +" and surface area: " + surfaceArea + "."); // Sphere constructor should take name then radiusSphere sphere = new Sphere("My sphere", 4);name = sphere.getName();volume = round(sphere.volume(), 2);surfaceArea =…arrow_forwardTODO 2 Complete the TODO by finding the locations of the data samples for each iris flower type. Hint: Use the code for how we found all the setosa_locs as an example! Using iris_df, find the location of all the data sample locations for the versicolor class which has a label of 1. To do so, use NumPy's np.where() function. Using iris_df, find the location of all the data sample locations for the virginica class which has a label of 2. To do so, use NumPy's np.where() function. setosa_locs = np.where(iris_df['class'] == 0)[0] # TODO 2.1versicolor_locs = # TODO 2.2virginica_locs = todo_check([ (type(versicolor_locs) is np.ndarray, "'versicolor_locs' is not type np.ndarray. Make sure you indexed np.where() currently!"), (type(virginica_locs) is np.ndarray, "'virginica_locs' is not type np.ndarray. Make sure you indexed np.where() currently!"), (versicolor_locs[0] == 50, "'versicolor_locs' has an incorrect value"), (virginica_locs[0] == 100, "'virginica_locs' has an…arrow_forwardComplete the recursive drawBoxes() method so that it will draw all of the boxes in the image below. It currently only draws the first and smallest Box. Feel free to use a different shape if you do not like boxes.arrow_forward
- Assuming that MotorBicycle is a subclass of Bicycle, select all of the codes that overload the applyBrake method. To better view the option, right-click the image and select "Open image in new tab."arrow_forwardImplement the Board class. Make sure to read through those comments so that you know what is required. package p1; // You need a random number generator in order to make random moves. Use rand below private static final Random rand = new Random(); private byte[][] board; /** * Construct a puzzle board by beginning with a solved board and then * making a number of random moves. Note that making random moves * could result in the board being solved. * * @param moves the number of moves to make when generating the board. */ public Board(int moves) { // TODO } /** * Construct a puzzle board using a 2D array of bytes to indicate the contents * of the cells in the triangle. * * @param b a "triangular array" with 5 rows where row 0 has 1 * cell, row 1 has 2 cells, etc. */ public Board(byte[][] b) { board = Arrays.copyOf(b, b.length); } public void printBoard() { for (int i = 0; i < board.length; i++) { for (int j = 0; j < board[i].length; j++) {…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_forward
- One of the advantages of using decorator pattern is that it may result in having too many classes Select one: True Falsearrow_forwarddef fun_cities(adict, city): """ Question 7 - Given a dict that maps a fun activity to a list of cities where you could practice it, return the set of activities that one could practice at the provided city! - For an extra challenge, try doing this in one line (Optional). Args: adict (dict) city (str) Returns: set >>> activity_dict = {"Sightseeing": ["Venice", "Istanbul", "London"], "Kayaking": ["Venice", "Oslo", "Paris"], "Food Tasting": ["Paris", "Istanbul", "Mumbai"], "Going to the Theater": ["Paris", "Oslo", "London"]} >>> fun_cities(activity_dict, "Paris") {'Kayaking', 'Food Tasting', 'Going to the Theater'} >>> fun_cities(activity_dict, "Venice") {'Sightseeing', 'Kayaking'} # activity_dict = {"Sightseeing": ["Venice", "Istanbul", "London"], "Kayaking": ["Venice", "Oslo", "Paris"], # "Food Tasting": ["Paris", "Istanbul", "Mumbai"], "Going…arrow_forwardOverride the testOverriding() method in the Triangle class. Make it print “This is theoverridden testOverriding() method”. (add it to triangle class don't make a new code based on testOverriding in SimpleGeometricObject class.) (this was the step before this one) Add a void testOverriding() method to the SimpleGeometricObject class. Make it print“This is the testOverriding() method of the SimpleGeometricObject class”arrow_forward
- The atoms of different elements have different numbers of protons, neutrons and electrons. Electrons are negatively charged; protons are positively charged and neutrons have no charge. Write a definition for an atom class that contains: Fields for storing the numbers of protons, neutrons and electrons with appropriate visibility; Setter and getter methods for manipulating these fields, ensuring that the minimum value for electrons and protons is 1, and the minimum value for neutrons is 0; A constructor that initializes new objects of atom to be the smallest element (Hydrogen), for which the number of protons is 1, the number of neutrons is 0, and the number of electrons is 1. Write a new method for the atom class called ision that will return true or false, depending upon whether the atom is an ion. An atom is an ion if it is charged (i.e., if the number of electrons ≠ the number of protons). Write a new method for the atom class called getAtomicMassNumber that will calculate and…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_forwardCreate a class for regular pyramid and call it RegularPyramid. The RegularPyramid objects should be constructed by providing number of sides, side length, and the height length only.Your RegularPyramid should have the following methods:Method slantHeight for calculation of slant heightMethod baseCircumradius for calculation of the circumradius of the base polygon.Method basePerimeter for calculation of the base perimeter.Method baseArea for calculation of the base area.Method lateralArea for calculation of the lateral area.Method totalSurfaceArea for calculation of all surface areas.Method baseArea for calculation of the base area.Method volume for calculation of the regular pyramid volume.arrow_forward
- 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