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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 11:00, jolleyrancher78
What are the possible consequences of computer hacking? what is computer piracy? describe some examples. what are the effects of computer piracy? what are the possible consequences of computer piracy? what is intentional virus setting? describe some examples. what are the effects of intentional virus setting? what are the possible consequences of intentional virus setting? what is invasion of privacy? describe some examples. what are the effects of invasion of privacy? what are the possible consequences of invasion of privacy? what is an acceptable use policy and what is the purpose of the acceptable use policy what is intellectual property and how can you use it?
Answers: 1
image
Computers and Technology, 23.06.2019 14:30, bernicewhite156
Select the correct answer. what does it indicate when a website displays https instead of http? a. the website is secure. b. there is no secure sockets layer. c. the secure sockets layer is hidden. d. the website is not secure.
Answers: 1
image
Computers and Technology, 23.06.2019 19:30, alangonsales6232
2. fluorine and chlorine molecules are blamed fora trapping the sun's energyob forming acid rainoc producing smogod destroying ozone molecules
Answers: 2
image
Computers and Technology, 24.06.2019 18:30, millie54
How does the use of e-mail benefit business communications? it can be sent at any time. it is faster than regular mail. it improves writing skills. it is less expensive than using a courier. it reduces the need for proofreading.
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 in other subjects: