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, 22.06.2019 07:00
Robots with telescoping arms are sometimes used to perform tasks (e.g., welding or placing screws) where access may be difficult for other robotic types. during a test run, a robot arm is programmed to extend according to the relationship r = 3 + 0.5cos(4θ) and the arm rotates according to the relationship θ=−π4t2+πt , where r is in feet, θ is in radians, and t is in seconds. use a computer program to plot the path of tip a in x and y coordinates for 0 ≤ t ≤ 4s.
Answers: 2
question
Computers and Technology, 22.06.2019 13:00
Write a program which asks you to enter a name in the form of first middle initial last. so you might enter for example samuel p. clemens. use getline to read in the string because it contains spaces. also, apparently the shift key on your keyboard doesn’t work, because you enter it all lower case. pass the string to a function which uses .find to locate the letters which need to be upper case and use toupper to convert those characters to uppercase. the revised string should then be returned to main in the form last, first mi where it will be displayed.
Answers: 1
question
Computers and Technology, 22.06.2019 17:30
Under which key category do the page up and page down keys fall? page up and page down keys fall under the keys category.
Answers: 1
question
Computers and Technology, 23.06.2019 00:30
Quic which one of the following is the most accurate definition of technology? a electronic tools that improve functionality b electronic tools that provide entertainment or practical value c any type of tool that serves a practical function d any type of tool that enhances communication
Answers: 1
You know the right answer?
The bigger picture - the objectlist (or arraylist (v1.0)) class a picture is simply a composition of...
Questions
question
History, 07.10.2019 11:30
question
Mathematics, 07.10.2019 11:30
Questions on the website: 13722362