PhoneBook (Sorting) You will be modifying your PhoneBook class to sort by different fields in a contact.

Similar documents
PhoneBook (Array List)

Cumulative Report Official DENTON COUNTY ELECTIONS GENERAL ELECTION November 02, 2010 Page 1 of 8

Medina County Domestic Relations Court Detail Schedule Mary Kovack:

Election Summary Report Clarke County State of Georgia Primary Election July 20, 2010 Summary For Jurisdiction Wide, All Counters, All Races

GEORGE W. MCAULEY JR., P.E. LESLIE S. RICHARDS. PennDOT Secretary of Transportation. Deputy Secretary for Highway Administration

RADFORD UNIVERSITY Division of Information Technology

Election Summary JACKSON COUNTY, MISSOURI GENERAL ELECTION NOVEMBER 4, 2014 (Official)

Date:05/24/18 Time:14:57:24 Page:1 of 8. Registered Voters Cards Cast % Num. Report Precinct 23 - Num. Reporting

November 2, 2004 Joint General and Special Elections Travis County November 02, 2004 Official Results Total Cumulative Report

Couples Chapman 2018 Player Roster

St. Timothy's Episcopal Church Worship and Liturgy Rota December 2014 through February 2015

Minister of Communion Schedule for November 4, 2016 to April 30, 2017

Minister of Communion Schedule for November 4, 2017 to April 29, 2018

HOPKINS COUNTY, TEXAS PRIMARY ELECTION 3/6/2018. Page 1 of 21. Election Day Voting Early Voting Total

Edward Sigda - Reader I Neil Coyne - Reader 2. Teresa O'Neill - Reader I Richard O'Neill - Reader 2. Ed Charlton - Reader I Grace Charlton - Reader 2

Views. Lecture 15. Robb T. Koether. Fri, Feb 16, Hampden-Sydney College. Robb T. Koether (Hampden-Sydney College) Views Fri, Feb 16, / 28

HOLY ANGELS CHURCH February 14 - May 27, 2018

Views. Lecture 15 Section 5.3. Robb T. Koether. Hampden-Sydney College. Mon, Feb 18, 2013

etcalf Metcalf Miles Results 30/38 Beginner overall Chief of Timing & Scoring Race Director Licensed to: Sierra OT

Views. Lecture 15 Section 5.3. Robb T. Koether. Hampden-Sydney College. Mon, Feb 18, 2013

Dekalb County, Indiana 2018 Primary Election INDEKP18 5/8/2018 6:00:00 AM

Stephen MANDEL 98, % Don KOZIAK 38, % Dave DOWLING 2, % George LAM 2, % Dustin BECKER 2, %

Date:05/24/18 Time:10:40:29 Page:1 of 6

Election Summary Report

Couples Chapman 2018 Player Roster

LICENSEE ACTION ACTION DATE Carl Michael Pozyck License Denial 1/20/2011 License #: Resident Accident Health Sickness

Tussing Elementary School Staff List School Administration

PUE_ _E August 10, 2010 Election Returns Pueblo County

HUD CONTACTS. Office of the Regional Administrator. Regional Administrator: Jane C. W. Vincent. Deputy Regional Administrator: Richard M.

Final Competition Rankings for the GGSM - BMT - 17 held at the Billings Rod and Gun Club in Billings, MT Match Date: 8/12/17

Tiger Trot 5K Age Group Results

HUD CONTACTS. Office of the Regional Administrator. Regional Administrator: Joseph J. DeFelice. Deputy Regional Administrator: Richard M.

Carmichael, Don & Wanda. Benjamin, Tony. Blocker, Larry & Mary. Charney, Greg & Stacy. Bui, Huan & Oanh Bgoc. Click, Mary Jane

#53011 HIGHPOWER NMC MATCH 1/1/16 NRA

HUD CONTACTS. Office of the Regional Administrator. Regional Administrator: Joseph J. DeFelice. Deputy Regional Administrator: Richard M.

Wyoming County 2017 General Election

DATA_607_Project_1_MJU Md Jalal Uddin September 28, 2016

Cumulative Report Unofficial GENERAL ELECTION HELD ON OFFICIAL BALLOT FOR GIBSON COUNTY November 06, 2018 Page 1 of 7

Mary Ann Schill - Reader I Michelle Wu - Reader 2. Teresa O'Neill - Reader I Richard O'Neill - Reader 2

Guide for Members of the Public Requesting Information. This document is required by Minnesota Statutes, section 13.03, subdivision 2(b).

Pennsylvania Gaming Control Board Application Status Report As of November 21, Supplier Applications

Preliminary GLOCK Girls Side Match Rankings for the GGSM- POK-19 held at the Alpha Training Academy in Pryor Creek, OK. Match Date: 4/13/19

Contest Overview Data 2018 ONTARIO General Unofficial

LICENSEE ACTION ACTION DATE. Bernard D. Coble Voluntary Surrender 1/4/2013. Christopher R. Little License Surrender 1/18/2013

Energy Master Plan Stakeholder Meeting Summary

Cumulative Report - Unofficial MARTIN COUNTY, TEXAS - GENERAL ELECTION - November 06, 2018

Statement of Votes Cast Primary Election -- May 15, 2018 Republican. Precinct Committeeperson. Total % Kenneth W Medenbach

Election Summary Report DENT COUNTY, MO PRIMARY ELECTION Summary For Jurisdiction Wide, All Counters, All Races OFFICIAL RESULTS

PRINCIPLES The IT Infrastructure Coordinating Committee is focused on acting as a steering committee for IT infrastructure issues with a charge to:

2013 NRA National Hunter s Pistol Silhouette Champion Preston W. Gibson 105 X 120

Wyoming County General Election

Date:05/23/18 Time:12:03:22 Page:1 of 9

MAGISTRATE COURT OF COBB COUNTY ORDINANCE CALENDAR JUDGE GERALD MOORE

SAL_ _E. November 8, 2016 Summary Report Salem County, NJ Official Results

ITS Management Team. January 17, Associate Vice Chancellor/CIO. Sharyne Miller. Executive Director Infrastructure & Operations Services

SNOW PLOW COMPETITION FINAL RESULTS

Larimer County Building Certificate of Occupancy Permits Issued between 01/01/2017 and 01/31/2017

ISP. Program Update June 2013 Chicago, IL

Hearing Type CaseType. Group ID Session: 1 9:00 AM Bail Hearing. Bail Hearings (MEH) Dec CR- Defender, Strafford Criminal

Regional Water Cooperative of Pierce County

Charlotte 49ers. Charlotte Athletics 9201 University City Blvd. Charlotte, NC *Address Applies to All * Please include Att:

Election Summary Report April 26, 2016 General Primary Election Armstrong County, PA Official Results

Final GLOCK Girl Side Match Rankings for the GGSM - BMT - 18 held at the Billings Rod and Gun Club in Billings, MT Match Date: 8/11/18

5 Mile Run. cheese Challenge Overall Results. June 14, 2014

Governmental/Regulatory Affairs Advisory Group. Alphabetical Listing by Company

Election Summary Report 1999 Coordinated El Paso County, Colorado Summary for Jurisdiction Wide, All Races

Final Competition Rankings for the GGSM - FNY-14 held at the Pathfinder Fish & Game Club in Fulton, NY Match Date: 7/12/14

Cumulative Report - Unofficial Sl"ATE PRIMARY AND COUNTY GENERAL ELECTION HELD ON - OFFICIAL BALLOT FOR LOUDON COUNTY - August 02,2018 Page 1of7

PHELPS ROAD PROPOSED PERMANENT CULVERT SEE DRAINAGE ANALYSIS REPORT IN APPENDIX E IN VOLUME I FOR ADDITIONAL INFORMATION SUFFIELD METACOMET TRAIL STR

Committee List 2016/2017

The Armidale School Old Boys Union Inc Committee List 2013/2014

David Pitney (Manager)

Squirt Divisions

Rev. Aas, Wallace (Wally) st Ave Ct. Greeley, CO Home: Joined: DOB

RFA Solicitation of Interest Respondents

Division of Information Technology

SPONSOR/AFFILIATE MEMBER ROSTER 2014

Donor Management with GiftWorks

Match Results NRA Regional Match on 4/23/ Shooters

Donor Management with GiftWorks. The Big Picture... 2 A Closer Look... 2 Scenarios... 4 Best Practices Conclusion... 21

2011 WEMSeries - Levis / Trow 100

CIRCUIT COURT FOR HARFORD COUNTY. MAGISTRATE FREDERICK J HATEM JR 18 Office Street MONDAY, JANUARY 08, 2018

People & Technology. Proceedings of the Bellcore/BCC Symposium on User-Centered Design: Bellcore. R 3"hX SR-STS

Office of the CIO. Marcela Hernandez Chief Data Officer. Don Thompson Chief Information Security Officer

Craig Woolley Chief Information Officer (97 including 7 Vacant)

CHAMBERS COUNTY, TEXAS PRIMARY ELECTION 3/6/2018. Page 1 of 14. Cast Votes: % % % %

Backstage Table Parent

Election Summary Report Saline County, IL General Primary Election Summary For Jurisdiction Wide, All Counters, All Races UNOFFICIAL FINAL RESULTS

Brazoria County Joint Primary Election 3/6/2018. Page 1 of 13. Choice Party Absentee Early Voting Election Day Total

Brazoria County Joint Primary Election 3/6/2018. Page 1 of 13. Choice Party Absentee Early Voting Election Day Total

EduCALC: A Look Back Jake Schwartz

PROFESSIONAL DEVELOPMENT FACULTY STIPENDS

Pete Yarbro 2-MA 3-FTR st FTR Rick Frost 4-SS 3-FTR

Office Staff Position First Name Last Phone Number

********** 5K RUNNERS AWARDS LIST ********** ********** FEMALE OVERALL 5K RUN RESULTS **********

Fall Conference Interconnecting with People and

St.Vincent Foundation Board of Directors

YTD Check Register REGION 9 ESC Sort by Check Number

Nueces County, Texas Joint Primary Election 3/6/2018. Page 1 of 16. Cast Votes: % % %

Counted Total Percent Ballots Registered Percent % 8,365. Counted Total Percent Ballots Registered Percent

Transcription:

PhoneBook (Sorting) Background: You will be modifying your PhoneBook class to sort by different fields in a contact. Assignment: 1. Create a project called PhoneBookSort. Copy your PhoneBook class and Contact class from the PhoneBook project you completed earlier. 2. Add an additional constructor to the PhoneBook class. It should take a single parameter: a String which is the name of a file that holds saved contact information. In this method, you are to open the file and read in all of the contacts and added them to your ArrayList. Each contact in the file is on a single line. The contacts are in two forms: Name PhoneNumber Name PhoneNumber SpeedDial 3. You should add 3 public static final variables to the PhoneBook class: public static final int SORT_BY_NAME = 100; public static final int SORT_BY_PHONE_NUMBER = 200; public static final int SORT_BY_SPEED_DIAL = 300; 4. You will need to create 3 new classes that implement the Comparator interface for sorting Contacts: a. For SORT_BY_NAME, you will sort by the names in the phone book. b. For SORT_BY_PHONE_NUMBER, you will sort by the phone numbers in the phone book. c. Sorting for SORT_BY_SPEED_DIAL is more complicated. The first items in the sort should be the contacts with a speed dial, sorted by the speed dial number. Following the contacts with a speed dial should be the rest of the contacts sorted by name. 5. Modify the printphonebook method to accept one of the above 3 values. You should then change the printphonebook code to sort prior to outputting the data in the phone book. // // Loop through the ArrayList and prints the name and phone number for all // contacts. // If the phone book is empty, output // // The phone book is empty // public void printphonebook(int howtosort) { } a. For SORT_BY_NAME, use the comparator class you created to sort by name, and the output will look as it did before: // Name, Phone (SpeedDial) // or // Name, Phone b. For SORT_BY_PHONE_NUMBER, use the comparator class you created to sort by phone number. The output will change so that phone number comes first with a speed dial in parentheses if it exists: // Phone, Name (SpeedDial) // or // Phone, Name

c. For SORT_BY_SPEED_DIAL use the comparator class you created to sort by speed dial. The output changes as well: // SpeedDial Name, Phone // or // Name, Phone d. For any other value, throw an exception. What would be a good exception to throw? Driver: The PhoneBook.txt file should be downloaded and placed in the PhoneBookSort project before running the program. public class PhoneBookDriver { public static void main(string[] args) { PhoneBook pb = new PhoneBook("PhoneBook.txt"); System.out.println("SORT BY NAME"); pb.printphonebook(phonebook.sort_by_name); System.out.println("SORT BY PHONE NUMBER"); pb.printphonebook(phonebook.sort_by_phone_number); } } System.out.println("SORT BY SPEED DIAL"); pb.printphonebook(phonebook.sort_by_speed_dial); Output: SORT BY NAME Albert, 213-554-7612 Alex, 213-890-4589 Amy, 714-237-8945 Annabelle, 714-489-7812 Ashley, 213-890-9632 Avery, 678-890-4523 (9) Barbara, 450-891-5632 Billy, 480-690-1208 Bob, 718-890-5600 Brian, 562-480-5585 (2) Chad, 562-890-0045 Christine, 780-890-1236 Christy, 450-138-4567 Cindy, 480-602-7812 David, 714-890-1289 Debbie, 703-456-8974 Dennis, 562-480-1569 Diane, 714-892-7830 Donna, 562-745-5568 Edward, 562-879-1275 Elizabeth, 213-856-9885

Eric, 245-874-8912 Erick, 245-785-9612 Evelyn, 213-890-4562 Fawn, 609-213-8845 Frank, 213-890-7812 Gary, 213-785-8899 Gayle, 568-890-0056 Glenda, 562-781-8823 Hank, 714-890-7889 Helen, 213-562-7812 Henry, 412-450-8900 Irene, 562-412-3789 Isabel, 213-890-4562 Ivy-Joan, 450-780-0045 Jack, 562-562-1900 Jackie, 714-892-4566 Jackson, 213-489-7812 James, 450-456-7889 Jane, 714-562-7800 Janet, 213-781-7823 Jeanne, 457-891-5645 Jennifer, 213-785-4563 Jenny, 213-895-7813 Jenzi, 562-480-7787 (1) Jessica, 403-745-8002 Jim, 714-230-8023 Joan, 256-879-4569 Joe, 562-480-1243 (7) John, 323-567-4589 Jordan, 645-756-7812 Joseph, 323-678-1256 (8) Josh, 412-812-8896 Josie, 323-678-1290 Julia, 602-412-5784 (0) Katharine, 602-812-6478 Kathy, 602-412-5213 Kaye, 278-189-4588 Keith, 245-712-8002 Ken, 602-789-1256 (3) Kenny, 310-234-7890 Kimberly, 213-889-6530 Larry, 450-789-4899 LeeAnn, 450-789-1278 Leila, 213-745-7836 Leslie, 602-745-7123 Lily, 714-562-7845 Lisa, 213-745-1277 Lynn, 602-960-7845 (4) Margaret, 602-589-1275 Maria, 562-480-4512 Marilyn, 403-478-5837 Mark, 562-789-1890 Marshay, 323-545-8900 Martin, 562-745-1278 Melody, 213-278-5003 Mercedes, 410-222-5678 Michael, 213-555-1289 Nancy, 245-875-8127 Nathan, 323-555-3456

Nicholas, 310-345-8923 Pamela, 562-480-7158 Patrick, 480-478-7879 Patty, 562-781-2323 Paul, 714-879-1278 Peter, 714-820-7312 (5) Richard, 562-478-8900 Robert, 480-562-7812 Rodney, 310-555-6897 Ronald, 562-741-1890 Sandra, 478-822-7349 Scott, 578-820-7319 Sharon, 562-712-7304 Sheryl, 450-712-8173 Stan, 609-719-5736 Steve, 703-731-8570 Susan, 639-450-7318 Ted, 639-457-5873 Thomas, 714-562-2346 Tim, 703-480-2971 Tony, 562-718-9170 Victor, 563-717-1597 (6) William, 563-735-8104 Zachary, 274-847-9610 SORT BY PHONE NUMBER 213-278-5003, Melody 213-489-7812, Jackson 213-554-7612, Albert 213-555-1289, Michael 213-562-7812, Helen 213-745-1277, Lisa 213-745-7836, Leila 213-781-7823, Janet 213-785-4563, Jennifer 213-785-8899, Gary 213-856-9885, Elizabeth 213-889-6530, Kimberly 213-890-4562, Evelyn 213-890-4562, Isabel 213-890-4589, Alex 213-890-7812, Frank 213-890-9632, Ashley 213-895-7813, Jenny 245-712-8002, Keith 245-785-9612, Erick 245-874-8912, Eric 245-875-8127, Nancy 256-879-4569, Joan 274-847-9610, Zachary 278-189-4588, Kaye 310-234-7890, Kenny 310-345-8923, Nicholas 310-555-6897, Rodney 323-545-8900, Marshay 323-555-3456, Nathan 323-567-4589, John 323-678-1256, Joseph (8)

323-678-1290, Josie 403-478-5837, Marilyn 403-745-8002, Jessica 410-222-5678, Mercedes 412-450-8900, Henry 412-812-8896, Josh 450-138-4567, Christy 450-456-7889, James 450-712-8173, Sheryl 450-780-0045, Ivy-Joan 450-789-1278, LeeAnn 450-789-4899, Larry 450-891-5632, Barbara 457-891-5645, Jeanne 478-822-7349, Sandra 480-478-7879, Patrick 480-562-7812, Robert 480-602-7812, Cindy 480-690-1208, Billy 562-412-3789, Irene 562-478-8900, Richard 562-480-1243, Joe (7) 562-480-1569, Dennis 562-480-4512, Maria 562-480-5585, Brian (2) 562-480-7158, Pamela 562-480-7787, Jenzi (1) 562-562-1900, Jack 562-712-7304, Sharon 562-718-9170, Tony 562-741-1890, Ronald 562-745-1278, Martin 562-745-5568, Donna 562-781-2323, Patty 562-781-8823, Glenda 562-789-1890, Mark 562-879-1275, Edward 562-890-0045, Chad 563-717-1597, Victor (6) 563-735-8104, William 568-890-0056, Gayle 578-820-7319, Scott 602-412-5213, Kathy 602-412-5784, Julia (0) 602-589-1275, Margaret 602-745-7123, Leslie 602-789-1256, Ken (3) 602-812-6478, Katharine 602-960-7845, Lynn (4) 609-213-8845, Fawn 609-719-5736, Stan 639-450-7318, Susan 639-457-5873, Ted 645-756-7812, Jordan 678-890-4523, Avery (9) 703-456-8974, Debbie 703-480-2971, Tim 703-731-8570, Steve 714-230-8023, Jim

714-237-8945, Amy 714-489-7812, Annabelle 714-562-2346, Thomas 714-562-7800, Jane 714-562-7845, Lily 714-820-7312, Peter (5) 714-879-1278, Paul 714-890-1289, David 714-890-7889, Hank 714-892-4566, Jackie 714-892-7830, Diane 718-890-5600, Bob 780-890-1236, Christine SORT BY SPEED DIAL 0 - Julia, 602-412-5784 1 - Jenzi, 562-480-7787 2 - Brian, 562-480-5585 3 - Ken, 602-789-1256 4 - Lynn, 602-960-7845 5 - Peter, 714-820-7312 6 - Victor, 563-717-1597 7 - Joe, 562-480-1243 8 - Joseph, 323-678-1256 9 - Avery, 678-890-4523 Albert, 213-554-7612 Alex, 213-890-4589 Amy, 714-237-8945 Annabelle, 714-489-7812 Ashley, 213-890-9632 Barbara, 450-891-5632 Billy, 480-690-1208 Bob, 718-890-5600 Chad, 562-890-0045 Christine, 780-890-1236 Christy, 450-138-4567 Cindy, 480-602-7812 David, 714-890-1289 Debbie, 703-456-8974 Dennis, 562-480-1569 Diane, 714-892-7830 Donna, 562-745-5568 Edward, 562-879-1275 Elizabeth, 213-856-9885 Eric, 245-874-8912 Erick, 245-785-9612 Evelyn, 213-890-4562 Fawn, 609-213-8845 Frank, 213-890-7812 Gary, 213-785-8899 Gayle, 568-890-0056 Glenda, 562-781-8823 Hank, 714-890-7889 Helen, 213-562-7812 Henry, 412-450-8900 Irene, 562-412-3789 Isabel, 213-890-4562 Ivy-Joan, 450-780-0045

Jack, 562-562-1900 Jackie, 714-892-4566 Jackson, 213-489-7812 James, 450-456-7889 Jane, 714-562-7800 Janet, 213-781-7823 Jeanne, 457-891-5645 Jennifer, 213-785-4563 Jenny, 213-895-7813 Jessica, 403-745-8002 Jim, 714-230-8023 Joan, 256-879-4569 John, 323-567-4589 Jordan, 645-756-7812 Josh, 412-812-8896 Josie, 323-678-1290 Katharine, 602-812-6478 Kathy, 602-412-5213 Kaye, 278-189-4588 Keith, 245-712-8002 Kenny, 310-234-7890 Kimberly, 213-889-6530 Larry, 450-789-4899 LeeAnn, 450-789-1278 Leila, 213-745-7836 Leslie, 602-745-7123 Lily, 714-562-7845 Lisa, 213-745-1277 Margaret, 602-589-1275 Maria, 562-480-4512 Marilyn, 403-478-5837 Mark, 562-789-1890 Marshay, 323-545-8900 Martin, 562-745-1278 Melody, 213-278-5003 Mercedes, 410-222-5678 Michael, 213-555-1289 Nancy, 245-875-8127 Nathan, 323-555-3456 Nicholas, 310-345-8923 Pamela, 562-480-7158 Patrick, 480-478-7879 Patty, 562-781-2323 Paul, 714-879-1278 Richard, 562-478-8900 Robert, 480-562-7812 Rodney, 310-555-6897 Ronald, 562-741-1890 Sandra, 478-822-7349 Scott, 578-820-7319 Sharon, 562-712-7304 Sheryl, 450-712-8173 Stan, 609-719-5736 Steve, 703-731-8570 Susan, 639-450-7318 Ted, 639-457-5873 Thomas, 714-562-2346 Tim, 703-480-2971 Tony, 562-718-9170

William, 563-735-8104 Zachary, 274-847-9610