Define a class called car that implements the interface

Assignment Help Programming Languages
Reference no: EM131310176

The Car Class

Define a class called "Car" that implements the parameterized Comparable interface. Each object of this class represents a type of car. Your class must provide all the methods in the public interface. Be sure to properly document each method in this class.

The CarComparator Class

Define a class, "CarComparator", that implements the parameterized Comparator interface. The Compare method should compare cars by -year+make+model, where + denotes ascending order, - denotes descending order, and year, make and model are the primary, secondary and tertiary keys.

The CarSorter Class

Write a program, CarSorter, to test your Car and

CarComparator implementations. Suppose that you have a text file with each line containing the year, an integer, the make, a one-word string, and model, a string of one or more words, of a car. Write a program that reads the information about the cars from the file and stores them in an array list of objects of the Car class.

For example, the input file to the program could be carlot.txt whose contents are shown below:

1998 Honda Prelude

1998 Honda Accord

2006 Honda Ridgeline

1996 Ford Taurus

1996 Mitsubishi Eclipse

2015 Mitsubishi Galant

2010 Ford Fusion

2003 Mazda Protege 5

2002 Mazda Protege 5

2002 Isuzu Trooper

Your program should do the following:

1. prompt the user for the name of the input file,

2. read the data from the input file and store information about the cars in an array list of Car objects,

3. print the unsorted data from the array list to the screen, as shown below,

4. create another array list and an array that contain the same data as the original array list,

5. sort the second array list by the order defined by the Comparable interface, while leaving the original array list unsorted

6. prompt the user for the name of an output file and then display on the screen and write the information in the sorted array list to the file,

7. sort the array by the order defined by the Comparable interface,

8. prompt the user for the name of a second output file and then display on the screen and write the information in the sorted array to the file,

9. again, create a third array list and a second array that contain the same data as the original array list,

10. sort the third array list using a comparator of the CarComparator class,

11. prompt the user for the name of third output file and then display on the screen and write the information in the sorted array list to the file,

12. sort the second array using a comparator of the CarComparator class,

13. and, finally, prompt the user for the name of a fourth output file and then display on the screen and write the information in the sorted array to the file.

The input file may contain information about any number of cars. The output to the file and on the screen should be formatted as shown in the sample run below. Your program should use a try-catch statement to handle any potential IOException.

Enter the name of the input file -> carlot.txt

The Unsorted Array List of Cars

[Honda, Prelude, 1998]

[Honda, Accord, 1998]

[Honda, Ridgeline, 2006]

[Ford, Taurus, 1996]

[Mitsubishi, Eclipse, 1996]

[Mitsubishi, Galant, 2015]

[Ford, Fusion, 2010]

[Mazda, Protege 5, 2003]

[Mazda, Protege 5, 2002]

[Isuzu, Trooper, 2002]

Enter the name of the first output file -> mmya1.txt

The Sorted Array List of Cars By Make-Model-Year

------------------------------------------------

Ford Fusion 2010

Ford Taurus 1996

Honda Accord 1998

Honda Prelude 1998

Honda Ridgeline 2006

Isuzu Trooper 2002

Mazda Protege 5 2002

Mazda Protege 5 2003

Mitsubishi Eclipse 1996

Mitsubishi Galant 2015

Enter the name of the second output file -> mmya.txt

The Sorted Array of Cars By Make-Model-Year

-------------------------------------------

Ford Fusion 2010

Ford Taurus 1996

Honda Accord 1998

Honda Prelude 1998

Honda Ridgeline 2006

Isuzu Trooper 2002

Mazda Protege 5 2002

Mazda Protege 5 2003

Mitsubishi Eclipse 1996

Mitsubishi Galant 2015

Enter the name of the third output file -> ymmal.txt

The Sorted Array List of Cars By Year-Make-Model

------------------------------------------------

2015 Mitsubishi Galant

2010 Ford Fusion

2006 Honda Ridgeline

2003 Mazda Protege 5

2002 Isuzu Trooper

2002 Mazda Protege 5

1998 Honda Accord

1998 Honda Prelude

1996 Ford Taurus

1996 Mitsubishi Eclipse

Enter the name of the fourth output file -> ymma.txt

The Sorted Array of Cars By Year-Make-Model

-------------------------------------------

2015 Mitsubishi Galant

2010 Ford Fusion

2006 Honda Ridgeline

2003 Mazda Protege 5

2002 Isuzu Trooper

2002 Mazda Protege 5

1998 Honda Accord

1998 Honda Prelude

1996 Ford Taurus

1996 Mitsubishi Eclipse.

Reference no: EM131310176

Questions Cloud

Benefits of methodology for handling criteria creep : This issue is not confined to the TCSEC, but rather is a problem universal to all evaluation technologies. Discuss the benefits and drawbacks of the CC methodology for handling criteria creep.
What is ibm preferred stocks beta with respect to market : Suppose that you own IBM preferred stock that pays an annual, fixed, and perpetual dividend of $10 which is worth $100 per share. The market return is 12% and the risk-free rate is 4%. What is IBM preferred stock's beta with respect to the market?
Explain what you think the purpose of the law is : Discussion for HR Recruit and Selection. Describe the law chosen. Explain what you think the purpose of the law is
Dollar exchange rate with the iceland krona : The Celluloid Collar Corporation has $210,000 in tax loss carryforwards. The Bowstring Shirt Company, a firm in the 30% tax bracket, would be willing to pay (on a nondiscounted basis) the sum of ______________ for the carryforward alone. Three years ..
Define a class called car that implements the interface : Define a class called "Car" that implements the parameterized Comparable interface. Each object of this class represents a type of car. Your class must provide all the methods in the public interface.
What are the values of doing formal evaluation : The issue of binding assurance requirements to functional requirements versus treating them as mutually exclusive sets has been debated over the years. Which approach do you think is preferable, and why?
What are the legal challenges involved : Of the three options that Obama's executive order is intended to provoke, which do you think businesses are most likely to choose and why? Are there any other options? If so, what are they and what are the legal challenges involved
Can hdm and gypsy be used interchangeably : Contrast the goals of the Gypsy Verification Environment with those of HDM. In particular, when is using HDM appropriate, and when is using Gypsy appropriate? Can HDM and Gypsy be used interchangeably?
Organization influence decision making and the outcome : 1. How does the financial aspect of an organization influence decision making and the outcome? 2. What are the advantages and disadvantages of a firm's use of power purchasing parity? Provide an example.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a script to create a new product category

Write a script to create a new Product Category called ‘Shoes'. This category belongs under the category Clothing. Only ParentProductCategoryID and Name are required.

  Write pseudo code to put scores until e button is hit

The program will keep on prompting you to put more scores until you hit E button on your keyboard. Write one page statement to examine this problem.

  Create a very basic calculator map out the numeric keypad

Create a very basic calculator, map out the numeric keypad (17 buttons) and an EditText view. If text is given, prompt the user with a message that complains about the error.

  Impact of information technology breakdowns

In today is highly interconnected world, we take information systems and technology for granted. We realize the important role they play only when things go wrong or fail (i.e. breakdowns). To complete this assignment, you will be identifying two ..

  Create a matrix the same size as omega

EENG 330: Microelectronics - Create a frequency vector called, omega which has one row and whose columns contain the elements 0.0, 0.02, 0.04, ..., 7.0 such that MATLAB does not print out the result in the command window - Create a matrix the same ..

  What are the benefits of the two when developing a compiler

What is the difference between top-down and bottom-up parsing

  Write program to compute salary of employee

Write a program to compute the salary of an employee according to his/her grade assigned by employer. You should declare class named CalSalary whose private data members will be employee.

  Prevent stack smashing within an executable program

What is pseudocode, and how does it assist in code translation? What are two methods that can be employed to prevent stack smashing within an executable program?

  Write a program to transfer copy 400 bytes

Write a program to transfer (copy) 400 bytes from a block starting at $1000 to another block starting at $1500 in Assembly language

  Prepare cron file to performs level dump every day

Prepare a cron file which will regularly perform the following backups: performs level 5 dump every day which neither a level 0 nor level 2 dump is performed.

  The design and testing the design of learning environments

HCI projects will gravitate on the design and testing the design of learning environments. Design or improvement of a computer application to support; promote learning, identifying new means of using technology for fostering and assessing learning..

  Write prolog clauses to express the relationships

Write prolog clauses to express the relationships, given the parent relationship: grand-parent, sibling, cousin.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd