Write a third for loop to print the names of colleges in collegelist again. Write a second for loop to remove each school whose name has four letters. Write a for loop to print the names of the colleges in collegelist. Populate collegelist with the names of at least 5 colleges that you are applying to. Create an ArrayList called collegelist that can hold objects of type String. Complete the following items below to help you filter your college choices: a. In this program, we ll write a program to model your college choices along with an algorithm that will help narrow down your choices according to a complex statistical analysis. Modify the deleteallsongs() method so that the length of the ArrayList songlibrary is 0 after all the songs have been removed. Modify the totalplaytime() method so that the method works correctly with the ArrayList songlibrary. Modify the two-argument constructor to create and populate the ArrayList songlibrary. Complete the following to complete the upgrade: a. (BlueJ) Upgrade the MyPhone to a MyPhone2 to use an ArrayList instead of an array. print the information for your phone a second time to verify that all songs have been deleted. call the deleteallsong() method for your phone, vi. print the result of the MyPhone method totalplaytime(). print the information for your MyPhone object using the tostring() method of the MyPhone class, iv. The songlibrary will be populated in the multiargument constructor. initialize its instance variables using its multi-argument constructor. create a MyPhone object called phone, ii. Ģ Write a MyPhoneDriver to perform the following: i. a tostring() method to display the object s three instance variables (including songlibary) in a user-friendly format. a brain method called deleteallsongs() that will remove all songs from memory by placing null into each element in the array. a brain method called totalplaytime() that will return an integer for the total number of seconds for all songs stored in the songlibrary. You can populate the songlibrary in the constructor with four songs of your choice in the two-argument constructor. a two-argument constructor to initialize the instance variables color and memorycapacity. an instance variable of type array that can hold 4 Song objects called songlibrary that will store the songs in the MyPhone, d. an instance variable for its memory capacity (in GB), c. Class MyPhone should include the following: a. Using one object as a container (the MyPhone class) to store another type of object (the array of Songs) is called class composition or the building of an object using other objects as its components. This can be done by copying the Song.java file from your P3AProject folder into your P4AProject folder. You can use your Song class from P3A in this project. We ll do this by adding an instance variable that is an array of type Song to your MyPhone class. Your MyPhone will include some information about the phone as well as your music library. (BlueJ) In this program we will write a MyPhone class to represent your company s new smart phone. If (actor = r1 & Greenfoot.1 AP Computer Science Homework Set 4 Class Composition P4A. Create a new world with 600x400 cells with a cell size of 1x1 pixels.Ĭase 0: actor = r1 break //or whatever your image files are named * Constructor for objects of class MyWorld. You need to build a bar image also and combine them by drawing both the text and bar images on an image sized to contain both. Well, it was just an idea.Īt any rate, at this point, you have it showing only text. You could add a method to link a different GreenfootSound object to it. However, I was thinking it would be nice if you just supplied the GreenfootSound object whose volume it is to display and let the CurrentVolume object control itself. (4) the font size is a parameter in the GreenfootImage constructor, so with (3), lines 36 and 37 would not be needed Ĭurrently, your CurrentVolume class is really close to being like a cross between the Label and Score classes (which is not a bad thing). (3) it is probably better to create a new image (when needed) rather than clearing and redrawing it (2) the act method is causing the image to be unnecessarily recreated (cleared and redrawn) every act cycle (1) the GreenfootImage constructor call on line 15 is missing both Color parameters
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |