Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Re questing help with a two part assignment: Questions: Clock.java /** * Store details of club memberships. * * @author (your name) * @version (a

Re questing help with a two part assignment:

Questions:

image text in transcribed

image text in transcribed

Clock.java

/** * Store details of club memberships. * * @author (your name) * @version (a version number or a date) */ public class Club { // Define any necessary fields here ... /** * Constructor for objects of class Club */ public Club() { // Initialise any fields here ... }

/** * Add a new member to the club's list of members. * @param member The member object to be added. */ public void join(Membership member) { }

/** * @return The number of members (Membership objects) in * the club. */ public int numberOfMembers() { return 0; } }

Clock.java Ends

Membership.java

/** * Store details of a club membership. * * @author David J. Barnes and Michael Klling * @version 2016.02.29 */ public class Membership { // The name of the member. private String name; // The month in which the membership was taken out. private int month; // The year in which the membership was taken out. private int year;

/** * Constructor for objects of class Membership. * @param name The name of the member. * @param month The month in which they joined. (1 ... 12) * @param year The year in which they joined. */ public Membership(String name, int month, int year) throws IllegalArgumentException { if(month 12) { throw new IllegalArgumentException( "Month " + month + " out of range. Must be in the range 1 ... 12"); } this.name = name; this.month = month; this.year = year; } /** * @return The member's name. */ public String getName() { return name; } /** * @return The month in which the member joined. * A value in the range 1 ... 12 */ public int getMonth() { return month; }

/** * @return The year in which the member joined. */ public int getYear() { return year; }

/** * @return A string representation of this membership. */ public String toString() { return "Name: " + name + " joined in month " + month + " of " + year; } }

Membership.java Ends

tu surve a particular problem. g iem right can make it a lot easier Exercise 4.40 Use the club project to complete this and the following exercises. Your task is to complete the Club class, an outline of which has been provided in the project. The Club class is intended to store Membership objects in a collection. Within Club, define a field for an ArrayList. Use an appropriate import statement for this field, and think carefully about the element type of the list. In the constructor, create the collection object and assign it to the field. Make sure that all the files in the project compile before moving on to the next exercise. Exercise 4.41 Complete the numberOfMembers method to return the current size of the collection. Until you have a method to add objects to the collection, s return zero, of course, but it will be ready for further testing later. Exercise 4.42 Membership of a club is represented by an instance of the Membership class. A complete version of Membership is already provided for you in the club project, and it should not need any modification. An instance contains details of a person's name and the month and year in which they joined the club. All membership details are filled out when an instance is created. A new Membership object is added to a Club object's collection via the Club object's join method, which has the following description: Add a new member to the club's collection of members. * eparam member The member object to be added public void join (Hembership member) Complete the join method

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2016 Riva Del Garda Italy September 19 23 2016 Proceedings Part 3 Lnai 9853

Authors: Bettina Berendt ,Bjorn Bringmann ,Elisa Fromont ,Gemma Garriga ,Pauli Miettinen ,Nikolaj Tatti ,Volker Tresp

1st Edition

3319461303, 978-3319461304

Students also viewed these Databases questions

Question

Brief the importance of span of control and its concepts.

Answered: 1 week ago

Question

What is meant by decentralisation?

Answered: 1 week ago

Question

Write down the Limitation of Beer - Lamberts law?

Answered: 1 week ago