Sorting an Array of Cars/ Displaying in a GUI/Creating a Class Create a class called Car...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Sorting an Array of Cars/ Displaying in a GUI/Creating a Class Create a class called Car to represent a car. It should have four private instance variables: A String for the make, a String for the model, an int for the year and an int for the mileage. The class should include a four-argument constructor and get and set methods for each instance variable. Override the method to String which should return the Car information in the same format as the input file (See below). Read the information about a car from a file that will be given to you on Blackboard, parse out the four pieces of information for the Car using a StringTokenizer, instantiate the Car and store the Car object in two different arrays (one of these arrays will be sorted in a later step). Once the file has been read and the arrays have been filled, sort one of the arrays by Make using Selection Sort. Display the contents of the arrays in a GUI that has a GridLayout with one row and two columns. The left column should display the cars in the order read from the file, and the right column should display the cars in sorted order The input file Each line of the input file will contain information about a car, with each piece of information separated by a comma. An example of the input file would be: Toyota, Camry, 2017, 41001 Subaru, Forester, 2008,38913 If the line of the file does not have exactly four tokens, do not put it in the arrays; print it to the console. Submitting the Project. You should have three files to submit for this project: Project1.java CarGUI.java Car.java Sorting an Array of Cars/ Displaying in a GUI/Creating a Class Create a class called Car to represent a car. It should have four private instance variables: A String for the make, a String for the model, an int for the year and an int for the mileage. The class should include a four-argument constructor and get and set methods for each instance variable. Override the method to String which should return the Car information in the same format as the input file (See below). Read the information about a car from a file that will be given to you on Blackboard, parse out the four pieces of information for the Car using a StringTokenizer, instantiate the Car and store the Car object in two different arrays (one of these arrays will be sorted in a later step). Once the file has been read and the arrays have been filled, sort one of the arrays by Make using Selection Sort. Display the contents of the arrays in a GUI that has a GridLayout with one row and two columns. The left column should display the cars in the order read from the file, and the right column should display the cars in sorted order The input file Each line of the input file will contain information about a car, with each piece of information separated by a comma. An example of the input file would be: Toyota, Camry, 2017, 41001 Subaru, Forester, 2008,38913 If the line of the file does not have exactly four tokens, do not put it in the arrays; print it to the console. Submitting the Project. You should have three files to submit for this project: Project1.java CarGUI.java Car.java
Expert Answer:
Answer rating: 100% (QA)
package comcheggcargui import javaawtGridLayout import javautilList import javaxsw... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
a) Analysts attempt to value ordinary shares, in order to determine if market values are correct. Identify and describe the more common methods of valuation. Include a detailed explanation of the...
-
During 2014, Rex Company purchased marketable equity securities as a short-term investment. These securities are classified as available for sale. The cost and fair values at December 31, 2014,...
-
There are two groups of mutually synchronized clocks K and K' moving relative to each other with a velocity v as shown in Fig. The moment when the clock A' gets opposite the clock A is taken for the...
-
The velocity potential for a certain inviscid flow field is \[ \phi=-\left(3 x^{2} y-y^{3} ight) \] where \(\phi\) has the units of \(\mathrm{ft}^{2} / \mathrm{s}\) when \(x\) and \(y\) are in feet....
-
The Mainor School District is about to establish a 30-machine computer lab. It is considering six alternative means of acquiring and nancing the machines: 1. Buy the machines outright; cost will be...
-
Identify and evaluate the components of a comprehensive total rewards and motivation system? Illustrate with specific examples.
-
List the people and groups of people who are likely to be interested in financial statements.
-
7 04:37:16 Check my work Use the Rydberg equation to calculate the frequency of a photon absorbed when the hydrogen atom undergoes a transition from n1=2 to n2 = 4. (R= x 107 m-1) 1.096776
-
Winston is disappointed in the new SUV he recently purchased. He was excited about the new technology incorporated in his SUV but they did not live up to his expectations; therefore, please...
-
Suppose you drop little balls of mass m on to a target marked on the floor. According to the uncertainty principle, the balls should not necessarily fall straight down even if you attempt to hold...
-
Maple syrup ( = 1300 kg/m 3 , = 0.1 Pas) flows through a pipe of cross-sectional area A = 0.1 m2 . Near the end of the pipe, an angled attachment is glued to the pipe to redirect the flow through an...
-
A 8 0 0 0 8 0 0 0 g mass of Mercury was dumped into the ocean 1 0 0 1 0 0 m off - shore of Miami Beach. The water in this region mixes in the x , , y , , and z direction at a turbulent diffusivity...
-
calculate the accessible income INCOME $ $ C - OTHER SALES OF GOODS AND SERVICES Sales of goods and services to Australian customers 525000 Exported sales of goods and services 65000 590000 H - TOTAL...
-
The Dreidel Company reported net income of $45,900 for the year ended December 31, 2024. January 1 balances in accounts receivable and accounts payable were $23,700 and $25,000 respectively. Year-end...
-
Multiple Choice Questions: 1. The largest component of aggregate demand is? a. Government purchases. b. Net exports. c. Consumption. d. Investment. 2. A reduction in personal income taxes, other...
-
Repeat any of the previous Practice Programs using JOptionPane, which is described in the graphics supplement at the end of Chapter 2.
-
A palindrome is a string that reads the same forward and backward, such as "radar". Write a static recursive method that has one parameter of type String and returns true if the argument is a...
-
Define an enumeration for each of the months in the year. Use a for-each statement to display each month.
-
One of the main fears that retail startups have is if they will be able to compete against Walmart, Home Depot, and the other big-box stores. This is a legitimate fear. Big-box stores continue to...
-
Influencer marketing is a type of marketing where companies partner with influencers, who have a significant following on social media platforms, to promote their products or services. Influencers...
-
In the summer of 2015, Stephen Kuhl and Kabeer Chopra made their way to Philadelphia to prepare for business school. It was their first semester in the Wharton MBA program. They were both in an...
Study smarter with the SolutionInn App