Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Hard copy: print ONLY your driver program AGNConsole.java source code file and the sample output showing all testing. Soft copy: export your entire project as a .jar file and submit it to turnitin....

1 answer below »

Hard copy: print ONLY your driver program AGNConsole.java source code file and the sample output showing all testing.

Soft copy: export your entire project as a .jar file and submit it to turnitin. Make sure ALL your .java source code files are included.

  • class ID: XXXXXXXXXX
  • enrollment password: BIT203

Expected Learning OutcomesAssessed

· CLO1: write programs using several classes based on UML class diagrams and other models;

· CLO2: apply object-oriented concepts in the design and implementation of the programs;

· CLO3: use and extend Java interfaces and classes in the implementation of their programs

Instructions

AGN Information System: Iteration 1

Acts Global Networking (AGN) is a non-profit organization that manages the Jinjang Utara Community Project for the poor. They required an information system to record contributions from donors, including sponsorships for children 18 and under. The information system planned to be developed in several iterations. In the first iteration, the information system must allow the AGN administrator to record information about children, donors and contributions received, as shown in Fig. 1.

Figure 1: AGN Use Case Diagram

The domain model classes that you must implemented are as shown in the class diagram in Fig. 2.

Figure 2: AGN Class Diagram

The Controller class AGN must maintain at least a collection of Child objects and a collection of Donor objects.

A Donor can make one or more contributions. Note that Contribution is an abstract class, as a contribution must be a material contribution, monetary contribution or a sponsorship. You must implement the abstract method getValue() in each of the subclasses, according to these calculations:

- The maximum value of each sponsorship of a child is RM150, as indicated by the static variable maxSponsorshipValue. A donor may provide a full sponsorship (100%) or a partial sponsorship, so the value of the sponsorship will be a percentage of RM150.

- The value of a Monetary Contribution is the amount that is donated.

- The value of a Material Contribution will be the product of the number of units and the value of each unit of the item contributed.

Associations between the classes are to be implemented according to the class diagram and as necessary to realize the use cases described.

The use cases of the system are described as follows:

Use Case 1

Record Child

Goal in Context

To record a child who needs sponsorship

Primary Actor

Secondary Actor

AGN administrator

Trigger

The AGN administrator receives information about a child who needs sponsorship.

Typical Course of Events

Actor Action

System Response

1. This use case begins when the AGN administrator wants to record information about a child who needs sponsorship.

2. The AGN administrator enters the child’s name, date of birth, home address and MyKad number

Check if the child is already registered.

Alternative Course of Events

Line 2a: If the child’s MyKad number is already in the system, allow the AGN administrator to update the child’s name, date of birth and home address.

Line 2b: If the child’s age is more than 18, cancel the use case as the child cannot be sponsored.

Use Case 2

Record Contribution

Goal in Context

To record a monetary donation, material donation or sponsorship from a donor

Primary Actor

Secondary Actor

AGN administrator

Trigger

The AGN administrator receives information about a donor who has made a contribution.

Typical Course of Events

Actor Action

System Response

1. This use case begins when the AGN administrator wants to record information about a donor who has made a contribution.

2. The AGN administrator enters the donor’s email address.

The donor’s name and email address are shown for an existing donor, together with the total value of all contributions made by the donor.

3. The AGN administrator selects the contribution type: material, monetary or sponsorship.

For a sponsorship, a list of children who do not have 100% sponsorship is shown.

4. For sponsorship, the AGN administrator selects a child to receive the sponsorship by entering the child’s MyKadNo, and enters the date and percentage of sponsorship.

The sponsorship is recorded for the child and the donor. The contributionNo is automatically generated.

Alternative Course of Events

Line 2a: If it is a new donor, the donor’s name and email is recorded.

Line 2b: If the AGN administrator does not want to record a new contribution, cancel the use case.

Line 3a: For material contribution, the date of contribution, description of the item contributed, category of material (eg. food, clothing, school supplies), value per unit and number of units contributed is recorded. The contributionNo of the contribution is automatically generated.

Line 3b: For monetary contribution, the date of contribution and the donation amount is recorded. The contributionNo of the contribution is automatically generated.

Use Case 3

View Contribution Records

Goal in Context

To view all contributions and pledges that have been made by donors

Primary Actor

Secondary Actor

AGN administrator

Trigger

The AGN administrator wants to view contributions

Typical Course of Events

Actor Action

System Response

1. This use case begins when the AGN administrator selects to view contribution records.

2. The AGN administrator enters the start and end date required and selects to sort by date, value or contribution type.

For each contribution within the start and end date inclusive, the contributionNo, contribution date, type of contribution (material, monetary, sponsorship), donor email and value are shown. The total value of all contributions within the start and end dates is displayed.

3. The AGN administrator selects a contributionNo to view details about the contribution.

For a sponsorship, the donor’s name, date of contribution, the percentage sponsored, value of sponsorship, sponsored child’s name, age and home address are shown.

Alternative Course of Events

Line 2a: If there are no contributions within the start and end date, show the message “No contributions”.

Line 2b: If the AGN administrator would like to view the list sorted by another category, repeat line 3.

Line 3a: For a material contribution, the donor’s name, date of contribution, material type, item description, value per unit, number of units contributed and value of contribution are shown.

Line 3b: For a monetary contribution, the donor’s name, date of contribution and donation amount are shown.

Line 3c: If the AGN administrator would like to view another contribution, repeat line 3.

Use Case 4

View Sponsorship Records

Goal in Context

To view the status of sponsorship for each child and the contributions received.

Primary Actor

Secondary Actor

AGN administrator

Trigger

The AGN administrator wants to view sponsorships

Typical Course of Events

Actor Action

System Response

1. This use case begins when the AGN administrator selects to view sponsorships

For each child, the child’s name, MyKadNo, home address, child’s current age and total percentage of sponsorship are shown.

2. The AGN administrator enters a child’s MyKadNo to view detail about a sponsorship.

For each sponsorship that the child receives, the name and email of the donor, percentage of sponsorship and value of the sponsorship are shown.

Alternative Course of Events

Line 2a: If the child has no sponsorships, indicate error.

Line 2b: If the AGN administrator would like to view detail about another child, repeat line 2.

Assignment Requirements:

User interface specifications

A Java application fulfilling the role of a user interface should be initiated in a class called AGNConsole. This class is not shown in the diagram (it is not a problem domain class) but is a view class that interacts with the AGN controller. The class should provide a console style user interface. That is, all output for the user should be directed to standard output (and appears on the screen) and all input should be obtained from standard input (read from the keyboard).

The AGNConsole class must contain the application's main method so that the application can be launched with a command equivalent to

java AGNConsole

User interaction and output

It is a specific requirement of this assignment that none of the problem domain classes listed above may contain any user interaction code, including the reading of values from a keyboard or interactive input device and none of the problem domain classes may generate any output for the user, such as screen messages or prompts.

It is acceptable (encouraged) to have screen output messages generated by problem domain classes for debugging purposes. These can be very useful during the implementation and testing phases of development. Debugging code should be removed or commented out of all problem domain classes in the final version of the application.

Design and implementation

In completing this assignment you should carefully consider the design of the system, one use case at a time. Once you have coded each class, test its functionality completely. You should only make use of 'getters' and 'setters' to access and alter attributes, and provide a toString method for each class.

You will need to design for and include the appropriate collection objects as well. You will also need to ensure that the data that is input by users is valid.

Coding style and comments

Your source code should be clear and readable, using correct indentation, meaningful identifiers and comments. Include javadoc comments and tags as follows:

  • for public classes, to indicate their purpose;
  • for public methods, to indicate their effect, parameters and return values, as well as any exceptions they throw;
  • for public fields, to indicate their purpose.

You will be expected to generate and submit the javadoc documentation for your classes as part of this assignment – included inside the submitted .jar.

What To Submit

You should submit the following as hard copy:

· Cover sheet

· The java source code files for all the driver program AGNConsole.

· Sample output that corresponds to the requirements of each use case.

· Marksheet

For soft copy:

· The soft copy of the hard copy submission, PLUS

· A .jar file containing all the Java source codes as well as its corresponding byte code files, and the Javadoc files in HTML format.

Answered Same Day Feb 19, 2020

Solution

Ujjawal answered on Feb 25 2020
152 Votes
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.A
ayList;
import java.util.List;
**
* Main class interacting with use
*
*
public class AGNConsole {
    static BufferedReader reader = null;
    /**
     * Main method
     * @param args
     *
    public static void main(String[] args) {
        AGN agnController = new AGN();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            
initiate an infinite loop
            while (true) {
                printMenu();
                String input = getUserInput();
                
use case 1 : Record a child
                if ("1".equals(input)) {
                    
ead MyKad numbe
                    System.out.println("Enter MyKad number");
                    String mykadNumber = getUserInput();
                    List children = agnController.getChildren();
                    boolean isChildExists = false;
                    Child existingChild = null;
                    
iterate over children
                    for (int i = 0; i < children.size(); i++) {
                        Child child = children.get(i);
                        
check if MyKad number matches with this child
                        if (child.getMykadNo().equalsIgnoreCase(mykadNumber)) {
                            isChildExists = true;
                            existingChild = child;
                            
eak;
                        }
                    }
                    
check if child existed
                    if (isChildExists) {
                        System.out.println("Child already exists in the system");
                        
check if child can be sponsored
                        if (existingChild.getAge() > 18) {
                            System.out.println("Child's age is more than 18. Child cannot be sponsored.");
                            continue;
                        }
                        System.out.println("Update child's details(y/n)?");
                        input = getUserInput();
                        
ask if details are to be updated
                        if ("n".equals(input)) {
                            continue;
                        }
                    }
                    
ead child details
                    System.out.println("Enter child name");
                    String childName = getUserInput();
                    System.out.println("Enter date of birth in format dd/MM/yyyy");
                    String dateOfBirth = getUserInput();
                    System.out.println("Enter home address");
                    String address = getUserInput();
                    
update details
                    if (isChildExists) {
                        existingChild.setChildName(childName);
                        existingChild.setDateOfBirth(LocalDate.parse(dateOfBirth, formatter));
                        existingChild.setHomeAddress(address);
                        System.out.println("Child updated successfully");
                    } else {
                        
add new child
                        Child newChild = new Child();
                        newChild.setChildName(childName);
                        newChild.setDateOfBirth(LocalDate.parse(dateOfBirth, formatter));
                        newChild.setHomeAddress(address);
                        newChild.setMykadNo(mykadNumber);
                        
add child to child list
                        children.add(newChild);
                        System.out.println("Child added successfully");
                    }
                } else if ("2".equals(input)) {
                    
use case 2
                    System.out.println("Enter donor email address");
                    
read donor's email
                    String email = getUserInput();
                    List donors = agnController.getDonor();
                    Donor donor = null;
                    
get the donor matching this email
                    for (int i = 0; i < donors.size(); i++) {
                        if (donors.get(i).getEmail().equalsIgnoreCase(email)) {
                            donor = donors.get(i);
                            
eak;
                        }
                    }
                    if (donor != null) {
                        System.out.println("Donor already exists");
                    } else {
                        
read new donor details
                        System.out.println("Donor not found. \nRecord a new contribution(y/n)?");
                        input = getUserInput();
                        
check if administrator wants to add new dono
                        if ("y".equalsIgnoreCase(input)) {
                            donor = new Donor();
                            
new dono
                            System.out.println("Enter donor's name");
                            String name = getUserInput();
                            donor.setDonorName(name);
                            System.out.println("Enter donor's email");
                            String donorEmail = getUserInput();
                            donor.setEmail(donorEmail);
                            System.out.println("Donor added successfully");
                            
add dono
                            agnController.getDonor().add(donor);
                        } else if ("n".equalsIgnoreCase(input)) {
                            
skip use case if new donor is not to be added
                            System.out.println("Administrator chose not to add...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here