A mountain climbing club maintains a record of the climbs that its members have made. Information about a climb includes the name of the mountain peak and the amount of time it took to reach the top. The information is contained in the ClimbInfo class as declared below.  The ClimbingClub class maintains a list of the climbs made by members of the club. The declaration of the ClimbingClub class is shown below. You will write implementations of the addClimb method.  import java.util.List;  import java.util.ArrayList;  class ClimbInfo  {  private String name;  private int time;  /** Creates a ClimbInfo object with name peakName and time climbTime.  *  * @param peakName the name of the mountain peak  * @param climbTime the number of minutes taken to complete the climb */  public ClimbInfo(String peakName, int climbTime)  {  name = peakName;  time = climbTime;  }  /** @return the name of the mountain peak */  public String getName()  {  return name;  }  /** @return the number of minutes taken to complete the climb */  public int getTime()  {  return time;  }  public String toString()  {  return "Peak name: " + name + " time: " + time;  }  }  public class ClimbingClub  {  /** The list of climbs completed by members of the club.  * * Guaranteed not to be null. Contains only non-null references.  */  private List climbList;  /** Creates a new ClimbingClub object. */  public ClimbingClub()  {  climbList = new ArrayList();  }  /** Adds a new climb with name peakName and time climbTime to the end of the list of climbs  *  * @param peakName the name of the mountain peak climbed  * @param climbTime the number of minutes taken to complete the climb  */  public void addClimb(String peakName, int climbTime)  {  // write implementation logic  }  public String toString()  {  String output ="";  for (ClimbInfo info : climbList)  {  output = output + info.toString() + "\n";  }  return output;  }  public static void main(String[] args)  {  // test  ClimbingClub hikerClub = new ClimbingClub();  hikerClub.addClimb("Monadnock", 274);  hikerClub.addClimb("Whiteface", 301);  hikerClub.addClimb("Algonquin", 225);  hikerClub.addClimb("Monadnock", 344);  System.out.print(hikerClub);  }  }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

A mountain climbing club maintains a record of the climbs that its members have made. Information about a climb includes the name of the mountain peak and the amount of time it took to reach the top. The information is contained in the ClimbInfo class as declared below. 

The ClimbingClub class maintains a list of the climbs made by members of the club. The declaration of the ClimbingClub class is shown below. You will write implementations of the addClimb method. 

import java.util.List; 

import java.util.ArrayList; 

class ClimbInfo 

private String name; 

private int time; 

/** Creates a ClimbInfo object with name peakName and time climbTime. 

* @param peakName the name of the mountain peak 

* @param climbTime the number of minutes taken to complete the climb */ 

public ClimbInfo(String peakName, int climbTime) 

name = peakName; 

time = climbTime; 

/** @return the name of the mountain peak */ 

public String getName() 

return name; 

/** @return the number of minutes taken to complete the climb */ 

public int getTime() 

return time; 

public String toString() 

return "Peak name: " + name + " time: " + time; 

public class ClimbingClub 

/** The list of climbs completed by members of the club. 

* * Guaranteed not to be null. Contains only non-null references. 

*/ 

private List<ClimbInfo> climbList; 

/** Creates a new ClimbingClub object. */ 

public ClimbingClub() 

climbList = new ArrayList<ClimbInfo>(); 

/** Adds a new climb with name peakName and time climbTime to the end of the list of climbs 

* @param peakName the name of the mountain peak climbed 

* @param climbTime the number of minutes taken to complete the climb 

*/ 

public void addClimb(String peakName, int climbTime) 

// write implementation logic 

public String toString() 

String output =""; 

for (ClimbInfo info : climbList) 

output = output + info.toString() + "\n"; 

return output; 

public static void main(String[] args) 

// test 

ClimbingClub hikerClub = new ClimbingClub(); 

hikerClub.addClimb("Monadnock", 274); 

hikerClub.addClimb("Whiteface", 301); 

hikerClub.addClimb("Algonquin", 225); 

hikerClub.addClimb("Monadnock", 344); 

System.out.print(hikerClub); 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY