Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
3rd Edition
ISBN: 9780134038179
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 12, Problem 6AW
Explanation of Solution
- The constructor of “GridLayout()” should pass the row and column value of layout manager. The definition of “GridLayout()” manager is given below:
GridLayout(row_value,column_value)
- If the class inherits from the “JFrame” class, the object variable of the class should call the method “setLayout()” to set the layout for content pane...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
a textbox for an optional search term, and a file upload field which allows them to upload a file which contains multiple lines of text (with the file each line should be treated as a separate string).
The user can enter a string and upload a file in the same submission of the form.
For the single string: if a search term is provided, output the string with the search term highlighted (by wrapping the term in a span with an appropriate class).
For the file upload:, if a search term is provided output only the strings that contain the search term (with the search term highlighted) and a count of the number of strings that did not have the term.
please do this in PHP and HTML only
Rectangle Object Monitoring
Create a Rectangle class that can compute the total area of all the created rectangle objects using static fields (variables). Remember that a Rectangle has two attributes: Length and Width. Implement the class by creating a computer program that will ask the user about three rectangle dimensions. The program should be able to display the total area of the three rectangle objects. For this exercise, you are required to apply all OOP concepts that you learned in class.
Sample output:
Enter Length R1: 1
Enter Width R1: 1
Enter Length R2: 2
Enter Width R2: 2
Enter Length R3: 3
Enter Width R3: 3
The total area of the rectangles is 14.00
Note: All characters in boldface are user inputs.
Q2 Create MusicOrganizer project using BlueJ .
(i) Create a MusicOrganizer class and declare an ArrayList for storing the file
names of music files into the String object.
(ii) Create a constructor for the music organizer class and assign the field to the
ArrayList.
(iii) Write a method to add a file to the collection.
(iv) Write a method to return the number of files in the collection.
(v) Write a method to remove a file from the collection.
(vi) Make a screen shot of the coding and output.
Chapter 12 Solutions
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Ch. 12.2 - Prob. 12.1CPCh. 12.2 - Prob. 12.2CPCh. 12.2 - Prob. 12.3CPCh. 12.2 - Prob. 12.4CPCh. 12.2 - Prob. 12.5CPCh. 12.2 - Prob. 12.6CPCh. 12.2 - If you are writing an event listener class for a...Ch. 12.2 - Prob. 12.8CPCh. 12.2 - Prob. 12.9CPCh. 12.3 - Prob. 12.10CP
Ch. 12.3 - Prob. 12.11CPCh. 12.3 - Which layout manager arranges components in a row,...Ch. 12.3 - Prob. 12.13CPCh. 12.3 - Prob. 12.14CPCh. 12.3 - Prob. 12.15CPCh. 12.3 - Prob. 12.16CPCh. 12.3 - Prob. 12.17CPCh. 12.4 - Prob. 12.18CPCh. 12.4 - Prob. 12.19CPCh. 12.4 - Prob. 12.20CPCh. 12.4 - Prob. 12.21CPCh. 12.4 - Prob. 12.22CPCh. 12.4 - Prob. 12.23CPCh. 12.4 - Prob. 12.24CPCh. 12.4 - Prob. 12.25CPCh. 12.5 - Prob. 12.26CPCh. 12.5 - Prob. 12.27CPCh. 12 - With Swing, you use this class to create a frame....Ch. 12 - Prob. 2MCCh. 12 - Prob. 3MCCh. 12 - Prob. 4MCCh. 12 - Prob. 5MCCh. 12 - Prob. 6MCCh. 12 - Prob. 7MCCh. 12 - Prob. 8MCCh. 12 - Prob. 9MCCh. 12 - Prob. 10MCCh. 12 - Prob. 11MCCh. 12 - Prob. 12TFCh. 12 - Prob. 13TFCh. 12 - Prob. 14TFCh. 12 - Prob. 15TFCh. 12 - Prob. 16TFCh. 12 - Prob. 17TFCh. 12 - Prob. 18TFCh. 12 - Prob. 19TFCh. 12 - Prob. 20TFCh. 12 - The following statement is in a class that uses...Ch. 12 - Prob. 2FTECh. 12 - Prob. 3FTECh. 12 - Prob. 4FTECh. 12 - Prob. 5FTECh. 12 - Prob. 1AWCh. 12 - Prob. 2AWCh. 12 - The variable myWindow references a JFrame object....Ch. 12 - Prob. 4AWCh. 12 - Prob. 5AWCh. 12 - Prob. 6AWCh. 12 - Prob. 7AWCh. 12 - Prob. 8AWCh. 12 - Prob. 9AWCh. 12 - Prob. 1SACh. 12 - Prob. 2SACh. 12 - Prob. 3SACh. 12 - Prob. 4SACh. 12 - Retail Price Calculator Create a GUI application...Ch. 12 - Prob. 2PCCh. 12 - Prob. 3PCCh. 12 - Travel Expenses Create a GUI application that...Ch. 12 - Prob. 5PCCh. 12 - Joes Automotive Joes Automotive performs the...Ch. 12 - Prob. 8PC
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- CODE IN JAVA Please look at the attached image for the information about the format the code should be in The code should be in two different .java files one with getFirstName, getLastName and getZipCode; the other file would be containing the main method Design and implement an application that reads a sequence of up to 25 pairs of names and postal (zip) codes for individuals. Store the data in an object of a class called “NameAndZip”, designed to store a first name (String), last name (String), and a postal code (int). Create a driver class called “NameAndZipList”. Assume that each line of input will contain two strings followed by an integer value. You will then create an object for each line read in and store that object in an array of NameAndZip objects. After the Names and Codes have been entered, print the list in an appropriate format to the screen using the toString method in the NameAndZip class. To test the program enter 3 names and codes.arrow_forwardDesign a class named Triangle that extends the GeometricObject class. The Triangle class contains:■ Three float data fields named side1, side2, and side3 to denote the threesides of the triangle.■ A constructor that creates a triangle with the specified side1, side2, andside3 with default values 1.0.■ The accessor methods for all three data fields.■ A method named getArea() that returns the area of this triangle.■ A method named getPerimeter() that returns the perimeter of this triangle.■ A method named _ _str_ _() that returns a string description for the triangle. For the formula to compute the area of a triangle, see Exercise 2.14. The_ _str_ _() method is implemented as follows:return "Triangle: side1 = " + str(side1) + " side2 = " +str(side2) + " side3 = " + str(side3)Draw the UML diagrams for the classes Triangle and GeometricObject.Implement the Triangle class. Write a test program that prompts the user to enter the three sides of the triangle, a color, and 1 or 0 to indicate…arrow_forwardDesign a GUI for Book view class for the following Library Information System, which you have worked on 1 with the following details: Library Item Class Design and TestingDesign a class that holds the Library Item Information, with item name, author, publisher. Write appropriate accessor and mutator methods. Also, write a tester program that creates three instances/objects of the Library Items class. Extending Library Item Class (Library and Book Classes): Extend the Library Item class in (1) with a Book class with data attributes for a book’s title, author, publisher and an additional attributes as number of pages, and a Boolean data attribute indicating whether there is both hard copy as well as eBook version of the book. Demonstrate Book Class in a Tester Program with an object of Book class.arrow_forward
- You will create a couple of classes that could be used to create a Text Adventure game. The class will be called "Item" and will represent an item in the game that can be carried and used by a player (such as a weapon or a tool). The Item Class The Item class will have only one property: A string description. The Item class will have exactly 3 methods: There will be a default constructor that takes no parameters. This constructor will give a generic, default description of the Item. There will be a constructor that takes a string parameter, and it will initialize the Item's description based on the parameter. There will be a method called "print" that will print the Item's description to standard output. PLEASE MAKE SURE ITS POSSIBLE TO COMPILE WITH THIS CODE. THANKS. #include "Item.h" #include <iostream> #include <string> using namespace std; int main() { Item sword("Sword of Destiny"); Item potion("Healing Potion"); Item key("Key of Wisdom"); string name; cout…arrow_forwardCreate the VisualCounter class, which supports both increment and decrement actions. Take the function Object() { [native code] }'s two arguments N and max, where N specifies the maximum action number and max specifies the counter's maximum absolute value. Make a plot that displays the worth of the counter each time its tally changes as a byproduct.arrow_forwardCompilation error Main. java:16: error: incompatible types: char[][] cannot be converted to char[] String string - String.copyValuedf(grid): Main. java:39: error: constructor CharGrid in class CharGrid cannot be applied to given types; grid- new CharGrid(nunRows, numCols); required: int, int, char found: int, nt reason: actual and formal argunent lists differ in lenath Note: Some messages have been simplified; recompile with-Xdiags:verbose to get full output 2 errors Hide Time limit: 8 seconds Memory limit: 256 MB 1// YOUR CODE HERE 2 class CharGrid( 3 private char[]] grid; 4. public CharGrid(int nunRows, int nunCols, char symbol){ 61 for (int i 0; 1< numRows: i++){ for (int j e; j< numCols; j++)( grid[i][j]- symbol; 8 10 11 12 13 String string String.copyValueof (grid): 14 15 C0verride 16 public String tostring() ( 17 return string: 18 19) 20 21 22 23 Submit Start over (reset)arrow_forward
- Create an interface RateConstants that includes a constant value for the subscription rate that is $15.5. Create a class NewspaperSubsciption that implements the RateConstants interface. A NewspaperSubscription class includes fields for the subscriber’s name and rate. The constructor requires data for name only. The rate should be set to the subscription rate of RateConstants. The name should not contain digits. If the name contains digits, raise an exception InvalidNameException. Create a class name InvalidNameException. The NewspaperSubscription class should throw an exception named InvalidNameException when it receives an invalid subscriber’s name. Create a class PhysicalNewspaperSubcription that extends NewspaperSubscription class. The PhysicalNewspaperSubscription class should have a field for subscription type and a constructor to sets the subscription type to “PhysicalSUB”. The PhysicalNewspaperSubscription class should also have a toString() method to displays all the…arrow_forwardIn an n-sided regular polygon, all sides have the same length and all angles have the same degree (i.e., the polygon is both equi-lateral and equiangular). Design a class named RegularPolygon that contains:■ ■ A private int data field named n that defines the number of sides in the polygon with default value 3. A private double data field named side that stores the length of the side with default value 1.■ ■ A private double data field named x that defines the x-coordinate of the poly-gon’s center with default value 0.■ ■ A private double data field named y that defines the y-coordinate of the poly-gon’s center with default value 0.■ ■ A no-arg constructor that creates a regular polygon with default values.■ ■ A constructor that creates a regular polygon with the specified number of sides and length of side, centered at (0, 0).■ ■ A constructor that creates a regular polygon with the specified number of sides, length of side, and x- and y-coordinates.■ ■ The accessor and mutator…arrow_forwardStockReader Class • This class will contain the method necessary to read and parse the .csv file of stock information. • This class shall contain a default constructor with no parameters. The constructor should be made private. . This is to prevent the class from being instantiated since the class will only contain static methods. • This class shall contain no data fields. • This class shall have a method called readStockData: . This method shall be a public, static, method. . This method shall return a StockList object once all data has been processed. . This method will take a File object as a parameter. This File object should link to the stock market data in your files folder created previously. . This method must validate that the given File object is a .csv file. If it is not, then this method shall throw an IllegalArgumentException. . This method shall read the File object and process all of the stock data into TeslaStock objects and store each object in a StockList. NOTE: The…arrow_forward
- Javaarrow_forwardAssume that a class named Window has been defined. The Window class has a member function named clone that takes no arguments and returns a pointer to a new copy of the Window object. Also, assume that a class named GraphicProgram has been defined with the following members: executableName, a variable of the string type windowPtr, a variable of the Window* type Write a copy constructor for the GraphicProgram class that uses the clone function to make a proper copy of the Window object that windowPtr points to. The executableName member may be copied using simple assignment. Don't use GraphicProgram:: notation. Also put in c++ formatarrow_forwardHelp find the classes, how they are utilized and how many objects were created in this code provided by me Source is provided, mainmenu.cpp is the images. and mainmenu.h is also provided. Source.cpp #include <SFML/Graphics.hpp>#include "MainMenu.h"#include <time.h>#include <SFML/Window.hpp> using namespace sf; int N = 30, M = 20;int size = 16;int w = size * N;int h = size * M; int dir, num = 4; struct Snake{ int x, y;} s[100]; struct Fruit{ int x, y;} f; void Tick(){ for (int i = num;i > 0;--i) { s[i].x = s[i - 1].x; s[i].y = s[i - 1].y; } if (dir == 0) s[0].y += 1; if (dir == 1) s[0].x -= 1; if (dir == 2) s[0].x += 1; if (dir == 3) s[0].y -= 1; if ((s[0].x == f.x) && (s[0].y == f.y)) { num++; f.x = rand() % N; f.y = rand() % M; } if (s[0].x > N) s[0].x = 0; if (s[0].x < 0) s[0].x = N; if (s[0].y > M) s[0].y = 0; if (s[0].y < 0) s[0].y = M; for (int i = 1;i < num;i++) if…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Graphical User Interfaces: Crash Course Computer Science #26; Author: CrashCourse;https://www.youtube.com/watch?v=XIGSJshYb90;License: Standard YouTube License, CC-BY
Python GUI | How To Make A GUI In Python | Best GUI Framework In Python | Edureka; Author: edureka!;https://www.youtube.com/watch?v=_PHJvjQJa3w;License: Standard Youtube License