Here is one question me and my friend are trying to solve.
Design, write in Java, test and document a prototype program for maintaining a registry of non-profit
organisations. The program must have at least two class definitions - an organisation class and a client
class of the organisation class.
The organisation class will have data members described as follows, which should be declared as
private:
(a) Organisation name (a string)
(b) Organisation ID number – a three digit number between 100 and 999
(c) Organisation’s registered address – house number and street name (a string), suburb (a string),
state (one of WA, SA, VIC, ACT, NSW, QLD, NT, and TAS) and postcode (a four digit number)
(d) The date of registration (day, month and year)
(e) The name of the Chairperson (a string)
(f) The number of executive committee members in addition to the Chairperson (up to four) and their
names (each of them a string).
The organisation class will have at least the following constructors and methods:
(i) two constructors - one without any parameters (the default constructor), and one with
parameters to give initial values to some instance variables.
(ii) a reasonable number of set and get methods
(iii) an input method and an output method
(iv) a method for comparing whether two organisations are the same entity based on the following
criteria
- either two organisations have the same organisation ID number, or
- two organisations have the same name and address (ignoring the cases of letters in the
name and address) and the same registration date.
(v) a method to determine whether a given person is an executive committee member of a
registered organisation (ignoring the cases of letters in the name)
(vi) a method to determine whether a given person is the Chairperson of a registered organisation
(ignoring the cases of letters in the name)
You may need to add other methods as you progress with the solution. For example, you may find that
it is better to have a method to handle a certain feature within the organisation class than outside of it.
The client program will allow entry of these data for several organisations into an array (the registry)
and then some analysis and queries.
Your client class (program) will provide the user with a menu which allows the following actions:
1. Quit (exit the program)
2. Add (to the registry) all information about a new organisation
3. View all information about an organisation chosen via the organisation’s ID number
4. View all information about an organisation chosen via the organisation’s name (ignoring case)
5. Edit (ie change) information about an organisation chosen via the organisation ID number
6. List the names of all organisations in the registry
7. List all organisations in which a given person serves as an executive committee member (a
person may serve as an executive committee member for more than one organisation)
8. List all organisations that were registered after a certain date
9. List the number of organisations in each state
10. Sort the registry (array) into ascending (alphabetical/dictionary) order of organisations’ names
(ignoring case), and output the sorted registry.
I started this question about half an hour back and I came up with something like this.
We need to use arrays, which makes it worse.
Could you correct me if I'm going wrong somewhere and also help me with the checking of the equality part?
Design, write in Java, test and document a prototype program for maintaining a registry of non-profit
organisations. The program must have at least two class definitions - an organisation class and a client
class of the organisation class.
The organisation class will have data members described as follows, which should be declared as
private:
(a) Organisation name (a string)
(b) Organisation ID number – a three digit number between 100 and 999
(c) Organisation’s registered address – house number and street name (a string), suburb (a string),
state (one of WA, SA, VIC, ACT, NSW, QLD, NT, and TAS) and postcode (a four digit number)
(d) The date of registration (day, month and year)
(e) The name of the Chairperson (a string)
(f) The number of executive committee members in addition to the Chairperson (up to four) and their
names (each of them a string).
The organisation class will have at least the following constructors and methods:
(i) two constructors - one without any parameters (the default constructor), and one with
parameters to give initial values to some instance variables.
(ii) a reasonable number of set and get methods
(iii) an input method and an output method
(iv) a method for comparing whether two organisations are the same entity based on the following
criteria
- either two organisations have the same organisation ID number, or
- two organisations have the same name and address (ignoring the cases of letters in the
name and address) and the same registration date.
(v) a method to determine whether a given person is an executive committee member of a
registered organisation (ignoring the cases of letters in the name)
(vi) a method to determine whether a given person is the Chairperson of a registered organisation
(ignoring the cases of letters in the name)
You may need to add other methods as you progress with the solution. For example, you may find that
it is better to have a method to handle a certain feature within the organisation class than outside of it.
The client program will allow entry of these data for several organisations into an array (the registry)
and then some analysis and queries.
Your client class (program) will provide the user with a menu which allows the following actions:
1. Quit (exit the program)
2. Add (to the registry) all information about a new organisation
3. View all information about an organisation chosen via the organisation’s ID number
4. View all information about an organisation chosen via the organisation’s name (ignoring case)
5. Edit (ie change) information about an organisation chosen via the organisation ID number
6. List the names of all organisations in the registry
7. List all organisations in which a given person serves as an executive committee member (a
person may serve as an executive committee member for more than one organisation)
8. List all organisations that were registered after a certain date
9. List the number of organisations in each state
10. Sort the registry (array) into ascending (alphabetical/dictionary) order of organisations’ names
(ignoring case), and output the sorted registry.
I started this question about half an hour back and I came up with something like this.
Code:
import java.util.Scanner;
public class Organisation {
/** data members described as follows below.
* which is declared as private */
private String organisationName;
private int organisationID;
/** Organisation’s registered address */
private int houseNumber;
private String streetName;
private String suburb;
private String state;
private int postcode;
/** The date of registration */
private int date;
private int month;
private int year;
private String chairpersonName;
/** Name of the executives and number of executives
* Maximum 4 executives */
private int numberOfExecutives;
private String executiveNames;
String[] orgName = new String[6];
int[] orgID = new int[6];
int[] houseNo = new int[6];
String[] stName = new String[6];
String[] sub = new String[6];
String[] stateName = new String[6];
int[] pCode = new int[6];
int[] dateJoined = new int[6];
int[] monthJoined = new int[6];
int[] yearJoined = new int[6];
String[] cpName = new String[6];
int[] execNum = new int[6];
String[] execNames = new String[6];
public Organisation()
{
organisationName = "Organisation name";
organisationID = 0000000;
houseNumber = 0000000;
streetName = "Street Name";
suburb = "suburb";
state = "state";
postcode = 0000;
date = 01;
month = 01;
year = 2013;
chairpersonName = "Chairperson Name";
numberOfExecutives = 4;
executiveNames = "Executive names.";
}
public String getOrganisationName() {
return organisationName;
}
public void setOrganisationName(String organisationName) {
this.organisationName = organisationName;
}
public int getOrganisationID() {
return organisationID;
}
public void setOrganisationID(int organisationID) {
this.organisationID = organisationID;
}
public int getHouseNumber() {
return houseNumber;
}
public void setHouseNumber(int houseNumber) {
this.houseNumber = houseNumber;
}
public String getStreetName() {
return streetName;
}
public void setStreetName(String streetName) {
this.streetName = streetName;
}
public String getSuburb() {
return suburb;
}
public void setSuburb(String suburb) {
this.suburb = suburb;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public int getPostcode() {
return postcode;
}
public void setPostcode(int postcode) {
this.postcode = postcode;
}
public int getDate() {
return date;
}
public void setDate(int date) {
this.date = date;
}
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public String getChairpersonName() {
return chairpersonName;
}
public void setChairpersonName(String chairpersonName) {
this.chairpersonName = chairpersonName;
}
public int getNumberOfExecutives() {
return numberOfExecutives;
}
public void setNumberOfExecutives(int numberOfExecutives) {
this.numberOfExecutives = numberOfExecutives;
}
public String getExecutiveNames() {
return executiveNames;
}
public void setExecutiveNames(String executiveNames) {
this.executiveNames = executiveNames;
}
public void inputInformation()
{
Scanner scan = new Scanner(System.in);
System.out.println("Enter organisation name: ");
organisationName = scan.nextLine();
System.out.println("Enter organisation ID: (only 3 digit numbers)");
organisationID = scan.nextInt();
System.out.println("Enter organisation's registered address: \n");
System.out.println("Enter house number: ");
houseNumber = scan.nextInt();
System.out.println("Enter street name: ");
streetName = scan.nextLine();
System.out.println("Enter suburb: ");
suburb = scan.nextLine();
System.out.println("Enter state: (WA, SA, VIC, ACT, NSQ, QLD, NT or TAS only)");
state = scan.nextLine();
System.out.println("Enter postcode: ");
postcode = scan.nextInt();
System.out.println("Enter the date of registration: \n");
System.out.println("Date: ");
date = scan.nextInt();
System.out.println("Month: ");
month = scan.nextInt();
System.out.println("Year: ");
year = scan.nextInt();
System.out.println("Enter Chairperson's name: ");
chairpersonName = scan.nextLine();
System.out.println("Enter the number of executives: (maximum 4 only!)");
numberOfExecutives = scan.nextInt();
System.out.println("Enter name of executives, please separate them with commas)");
executiveNames = scan.nextLine();
}
public void outputInformation()
{
int i = 0;
while(i <= 6)
{
orgName[i] = organisationName;
orgID[i] = organisationID;
houseNo[i] = houseNumber;
stName[i] = streetName;
sub[i] = suburb;
stateName[i] = state;
pCode[i] = postcode;
dateJoined[i] = date;
monthJoined[i] = month;
yearJoined[i] = year;
cpName[i] = chairpersonName;
execNum[i] = numberOfExecutives;
execNames[i] = executiveNames;
System.out.println("Do you want to enter more? (yes/no)");
Scanner input = new Scanner(System.in);
String option = input.nextLine();
if("yes".equals(option))
{
i++;
inputInformation();
continue;
}
else
{
break;
}
}
}
}
We need to use arrays, which makes it worse.
Could you correct me if I'm going wrong somewhere and also help me with the checking of the equality part?
Last edited: