subject

The bigger picture - the objectlist (or arraylist (v1.0)) class a picture is simply a composition of shapes, and in this last section, we'll build a class used to manage such a picture. we'll create this new class by reusing code from an existing piece of software. we'll create an objectlist class that will contain, amongst other state items (data), an array (or list) of objects that are the squares and circles in the picture to be drawn. objectlists will be a simple abstraction here, and will just "draw shapes to the console in the order that they appear in the list-ignoring the coordinate pairs stored in each shape for now. again, note the static storage restriction of only 100 shapes per picture; in future sections, we'll learn how to dynamically resize our arrays. aside: when we get to working with any of the java graphics framework classes and/or swing, then a simple use of this objectlist class (called a picturepanel extending jpanel) would accommodate for much more interesting shape behaviors and interactions. 1. copy-and-paste the intlist. java code into a new file called objectlist. java a. note this is the same process we used to quickly create the circle. java class 2. change the class name from intlist to objectlist. 3. change the instance variable that is your int[] array to an object ( array called myshapes. 4. change your public void add(int nx)" method to "public void add(object nx)" 5. remove functions and savel) and recompile using the provided shapes picture driver. java driver. 6. run your main and notice it still processes a list of integers correctly 7. now run the driver code and uncomment the objectlist segment and execute it. data members private object(myshapes; // used to be "data" this is an array of type object, which can thus store any object of any class . what about primitives? private int numelements; o this integer tracks the number of live shapes in our array method members void add object shape); o this function adds the circle or square to the array of circles @override public string tostring(): { //iterates through the array, calling tostring() on each shape and appending this //to one large string to be returned sample output alternate sample output questions & observations answer the following questions as multi-line comments in your code.. (1) why did we do so much copying-and-pasting in our software above? a. how can this approach be problematic? (2) are there obvious improvements that could be made here with respect the software design for squares and circles? (3) what programming constructs were you familiar with, and which did you need to look up? (4) assume we used a separate array for squares and for circles rather than one unifying object array. a. how would this complicate the task of adding a new shape (say, a triangle) to our objectlist class?

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 19:30
Write a function processpeople() that takes the name of a file as a parameter. each line of the file corresponds to information about a person. in particular a line contains either a name (in the form lastname,firstname with no spaces in it) or a name (lastname,firstname) and a year. the function will process the file, creating a person object for each line in the file. the function will print information about each line as it processes it, as well as appending the new person object into a list. make sure to use person methods to display information rather than recreating the work you did for the first problem. once the entire file has been processed, the function returns the list of person objects created from the file. if the file is empty, the function should return an empty list. if the input file cannot be opened, the function should print a message to that effect and then return an empty list. the following shows what would be displayed for two example files which have been provided in the link. the file none.txt does not exist. note that your function must work on an arbitrary file that consists of valid lines. you cannot assume anything about the file except that it contains lines that have the format described above.
Answers: 2
question
Computers and Technology, 21.06.2019 22:30
Ted wants to go out to a neighborhood park and shoot pictures of dew drops on grass. he wants to get a low-level angle of the dew drops. which support equipment should ted use? a. mini tripod b. pistol grip c. monopod d. body mount
Answers: 2
question
Computers and Technology, 24.06.2019 13:00
Refer to the figure and match the theorem that supports the statement.1.if chords are =, then arcs are =.if bc = de, then arc bc = arc de2.if arcs are =, then chords are =.if arc bc = arc de, then bc = de3.diameters perpen
Answers: 3
question
Computers and Technology, 24.06.2019 13:00
In a heat transfer course, we can derive the equation for the temperature distribution in a flat rectangular plate. in this example, we will look at a plate at steadystate with three sides being held at t1, and one side held at t2. the temperature for any location on the plate, t(x,y), can be calculated by where create a function (prob3_5) that will take inputs of vectors x and y in feet, scalar n, scalars l and w in feet and scalars t1 and t2 in degrees fahrenheit. it will output a matrix t which is the temperature of each x and y locations. t will have the number of columns equal to the number of elements in x and rows equal to the number of elements in y. though this can be done without loops (perhaps more efficiently), your program must use a nested loop.
Answers: 2
You know the right answer?
The bigger picture - the objectlist (or arraylist (v1.0)) class a picture is simply a composition of...
Questions
question
Mathematics, 23.04.2020 01:18
question
History, 23.04.2020 01:18
question
Mathematics, 23.04.2020 01:18
Questions on the website: 13722363