Question
Java: Acts Global Networking (AGN) is a non-profit organization that manages the Jinjang Utara Community Project for the poor. Their projects include organizing teachers for
Java: Acts Global Networking (AGN) is a non-profit organization that manages the Jinjang Utara Community Project for the poor. Their projects include organizing teachers for primary school children to help them improve their mathematics skills. For this assignment you will write a small application which can be used by AGN Staff to record children who need to be assigned teachers after taking your math quiz (from Assignment 1).
The application should enable AGN staff to record information about children. A child has a name, a level and the childs score on the math quiz. The application should allow the AGN staff to record information about a child, record the childs quiz score, assign a teacher to the child and upgrade the child if they have improved in their scores.
You are to write the following three classes:
The first is a class called Child which defines a simple object type representing an child
The second class called ChildList defines objects which are containers of Child objects.
The final class, called ChildListManager defines a Java application which creates one ChildList object and allows the various methods of ChildList to be called. This class will be an interactive application using the keyboard and the screen to interact with a human operator. It will not do calculations itself but will immediately pass user inputs as arguments to methods of ChildList class.
NOTE: The final application will only execute correctly when all three classes have been
defined completely and correctly but don't wait until you have completely written all three
before you start compiling and testing your code. It is recommended that you save all three
source code files in the same directory on your file system and compile and test each class as
you develop it using small separate programs to create and test objects of each class.
The .java files
The files you will be required to write are:
Child.java
This file defines a class of Child objects. The objects have the following instance variables:
childName, of type String;
level, of type int;
hasTakenQuiz, of type boolean
score, of type double.
teacherName, of type String.
The methods of class Child should include:
A constructor without arguments which will initialize the instance variables of the Child object to default values: unknown for childName, 0 for level, false for hasTakenQuiz, 0.0 for score and unassigned for teacherName .
A constructor with arguments which will initialise a Child object with the childs name and level passed in as arguments. The arguments should be validated: the childs name cannot be blank and level must be between 1 and 6 inclusive. If an argument is invalid the instance variable should be set to the default value. The score is set to 0.0, the boolean instance variable hasTakenQuiz is set to false and the teacher name is set as unassigned.
Setters for each of the instance variables, with validation to ensure that the instance variables are not changed if invalid.
The setters for the score and hasTakenQuiz instance variable are private, because the values can only be changed by another method inside the Child class.
Getters for each of the instance variables.
A method called recordScore() which receives a score, validates that it is between 0 and 100, sets the score to the parametric value and sets the hasTakenQuiz value to true.
A method called needsteacher() which receives a double value representing a cutoff score.
The method returns true the child has taken a quiz, does not have a teacher assigned and the score on the quiz is below the cutoff score.
Otherwise, the child does not need a teacher so the method should return false.
A method called upgrade() which increases the level by 1, sets the score to 0.0 and sets hasTakenQuiz to false. If the child is already at the maximum level, there are no changes.
A toString() method that returns a String:
if the child has taken the quiz,
Or if the child has not taken the quiz,
It is recommended that once you have written the Child class, you create a program to test it. The testing program should be placed in the same working directory as the Child class and be used to create one or two Child objects and call the Child methods. Compile the Child class and compile and run the test program to check your work.
ChildList.java
This file declares a class of object which maintains a collection of Child objects. It will contain methods to manage the collection as required by the menu requirements below.
This file should be saved into the same working directory as Child.java.
The ChildList class has two instance variables
an array of Child objects
an integer which stores the number of Child objects in the collection.
The ChildList class must also contain some methods which allow the collection of Child objects to be managed. These methods should include:
A constructor which accepts an integer which is used to set the size of the Child array. If the integer value passed in is negative, then an array of Child objects of size 50 is to be created. Otherwise, a Child array of the specific parametric value will be created. Then set the count to 0.
A method which accepts an parameter representing a Child. If the array is not full, the method adds the Child object passed as a parameter to the array and increments count by 1, and returns true. If the array is full, the method returns false.
A method named getChild() which accepts an String parameter representing the name of the child and returns a reference to the Child object in that cell of the array. If the name is not found, a null reference should be returned.
A method named showAllChildren() which returns a string containing information about all the children in the array, using the toString() method of the Child class.
Another method named showAllChildren() which receives a parameter representing a level and returns a string containing information about all the children with level matching the parameter, using the toString() method of the Child class.
A method which accepts an integer representing the level and returns the average score of all Child objects which are of that level.
A method which accepts a parameter representing a cutoff score and returns a list of children who score below the cutoff score and have not been assigned a teacher yet.
A method that will remove a Child object from the list decide on suitable parameters and the return type.
A method that will help find the top scorer(s) for each level.
You may write any other methods that you need to fulfill the required tasks that follow.
When you have written the ChildList class - test it by creating a ChildList object and invoking the methods from a small Java program.
ChildListManager.java
The aim of this class is to provide a user-interface for a modest application which uses a
ChildList container class and should be saved in the same working directory as the previous files. It is recommended that this user-interface be written as a 'console' application using the normal screen and keyboard to interact with a user via a simple text-based menu.
The ChildListManager program execution should :
Create a ChildList object with size specified by the user.
Show a menu with the following options:
Add a new Child
This option will prompt the user for the childs name and level and attempt to add a new Child to the ChildList. The child will not be added if the name or level is invalid, or if the ChildList already contains a child with the same name, or if the ChildList is already full.
Show all Children This option will show the information about all the Child objects in ChildList.
View Children who need teachers This option will allow the user to specify a cutoff score, and it will display all the children who need teachers based on the cutoff score.
View Average Score by Level This option will allow the user to specify a level and shows a list of all children of this level and the average score of all children of this level.
Show Top Scorers
This option will allow the user to view the information about the children with the highest quiz scores for each level.
Manage Child This option will allow the user to specify a child name. If the child is not found, show an error message. Otherwise, show current information about the child and allow the user to:
Record Quiz Score - enter the quiz score for the child.
Assign teacher to Child assign a teacher to the child by entering the teachers name
Upgrade Child upgrades the child to the next level.
Remove Child removes the child from the list
Quit.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started