Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Functional Requirements You will write a multi-class C++ interfacing prototype system for the Wildlife Zoo that incorporates Java for certain functionalities. The functional requirements for

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribed

image text in transcribed

Functional Requirements You will write a multi-class C++ interfacing prototype system for the Wildlife Zoo that incorporates Java for certain functionalities. The functional requirements for all components of the interface are as follows. 1. A user menu which displays the following options: Load Animal Data Generate Data Display Animal Data Add Record Delete Record Save Animal Data 2. Generate Data: Your supervisor has created this code for you in Java. In the C++ class you have been given, the createZooFile() function has been created for you. You should not modify the Java code. a. For this function, you should make sure the user menu calls the createZooFile() function when the user selects "Generate Data" from the menu. b. You will need to call this function and generate a file. When you are prompted for input, remember the following character limits: Track #: 6 characters ii. Name: 15 characters Type: 15 characters Sub-type: 15 characters Eees: Integer Nurse: Integer vi. 3. Load Animal Data: a. In your zipped folders, you have been given a Java class that generates a fixed length file. It will prompt the user to enter data for the following fields: Track #: Received from the RFID chip technology Name: Name given to the animal Type: Oviparous (ess laying) or Mammal (primarily non-ess laying) Sub-type: Crocodile, Bat, Whale, and so on Eees: Number of eggs laid Nurse: Should read o if the animal is not nursing 1 if it is b. Data in the file will look like this. Column widths in the actual file will be fixed and are respectively 6 characters, 15 characters, 15 characters, 15 characters, and two integer columns Eggs Track # 000001 DOC002 000003 000004 DOCOOS 000006 000007 000008 000009 000010 000011 Name Tick-Tock Fidget Willy Bailey Goose Lee Honker Becky Nigel Fluke Rudder Bartok Type Oviparous Mammal Mammal Mammal Oviparous Oviparous Oviparous Oviparous Mammal Mammal Mammal Sub-type Crocodile Bat Whale Whale Goose Goose Pelican Pelican Sealion Sealion Bat 2 0 0 0 0 1 1 0 0 0 0 Nurse 0 1 0 1 0 0 0 0 0 1 C. You must give users the ability to load this data into memory via a vector within your system. Use the following UML class diagram to build your class hierarchy and inheritance. Notice the variables listed in the Animal, Oviparous, and Mammal classes. A text version is available on the last page of this document. Animal Oviparous Numbers Mammal Crocodile Goose Pelican Bat Whale Sealion d. The message "Load complete will display after the data loads successfully. 4. Display Animal Data: Display data on the user's computer screen in tabular format (presented in the form of a table with rows and columns). S. Add Record: Provide the capability to add new animal records a. When this menu option is selected, the application should prompt the user to enter values for the variables "Track," "Name," "Type" "Sub-type," "Eggs," and "Nurse." i Make sure to validate input. b. The user should have the ability to save or cancel the addition 6. Delete Record: Provide the capability to delete animal records. a. Delete an animal record by "Trackit when the user selects the "Delete Record" option from the menu. 1. Make sure to validate input. b. The user should be prompted to confirm the deletion before the record is removed from the system. c. The message "Animal successfully deleted" should display once the operation finishes. 7. Save Data: Permit the user to save modified animal data back to the input file, erasing the data that was previously there. The message "Save successfully completed" should display once finished #include #include using namespace std; void GenerateData() //DO NOT TOUCH CODE IN THIS METHOD { JavaVM *jvm; // Pointer to the JVM (Java Virtual Machine) JNIEnv *env; // Pointer to native interface //======== prepare loading of Java VM ====== JavaVMInitArgs vm_args; // Initialization arguments JavaVMOption* options = new JavaVMOption[1]; // JVM invocation options options[0].optionString = (char*) "-Djava.class.path="; // where to find java .class vm_args.version = JNI_VERSION_1_6; // minimum Java version vm_args.nOptions = 1; // number of options vm_args.options - options; vm_args.ignoreUnrecognized = false; // invalid options make the JVM init fail load and initialize Java VM and JNI interface ============= jint rc = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args); // YES !! delete options; // we then no longer need the initialisation options. if (rc != JNI_OK) { // TO DO: error processing... cin.get(); exit(EXIT_FAILURE); } Display JVM version cout GetVersion(); cout > 16) & Oxof) "." (ver & 0x0f) FindClass("ZooFileWriter"); // try to find the class if (cls2 == nullptr) { cerr GetStaticMethodID(cls2, "create ZooFile", "V"); // find method if (mid == nullptr) cerr CallStaticVoidMethod(cls2, mid); cout Destroy JavaVM(); cin.get(); } void AddAnimal() { // TODO: Write proper code to add an animal to your vector (or array) } void RemoveAnimal() { // TODO: Write proper code to remove an animal from your vector (or array. Remmber to re-allocate proper size if using array) } void LoadDataFromFile() { // TODO: Write proper code to load data from input file (generated using JNI) into vector/array. } void SaveDataToFile() { // TODO: Write proper code to store vector/array to file. } void DisplayMenu() { // TODO: write proper code to display menu to user to select from } int main() { GenerateData(); return 1; } //////ZooFileWriter.java import java.io.FileWriter; import java.io. BufferedReader; import java.io.InputStreamReader; public class ZooFileWriter { public static String padleft(String str, int leng, String stringpadval) { for (int i = str.length(); i #include using namespace std; void GenerateData() //DO NOT TOUCH CODE IN THIS METHOD { JavaVM *jvm; // Pointer to the JVM (Java Virtual Machine) JNIEnv *env; // Pointer to native interface //======== prepare loading of Java VM ====== JavaVMInitArgs vm_args; // Initialization arguments JavaVMOption* options = new JavaVMOption[1]; // JVM invocation options options[0].optionString = (char*) "-Djava.class.path="; // where to find java .class vm_args.version = JNI_VERSION_1_6; // minimum Java version vm_args.nOptions = 1; // number of options vm_args.options - options; vm_args.ignoreUnrecognized = false; // invalid options make the JVM init fail load and initialize Java VM and JNI interface ============= jint rc = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args); // YES !! delete options; // we then no longer need the initialisation options. if (rc != JNI_OK) { // TO DO: error processing... cin.get(); exit(EXIT_FAILURE); } Display JVM version cout GetVersion(); cout > 16) & Oxof) "." (ver & 0x0f) FindClass("ZooFileWriter"); // try to find the class if (cls2 == nullptr) { cerr GetStaticMethodID(cls2, "create ZooFile", "V"); // find method if (mid == nullptr) cerr CallStaticVoidMethod(cls2, mid); cout Destroy JavaVM(); cin.get(); } void AddAnimal() { // TODO: Write proper code to add an animal to your vector (or array) } void RemoveAnimal() { // TODO: Write proper code to remove an animal from your vector (or array. Remmber to re-allocate proper size if using array) } void LoadDataFromFile() { // TODO: Write proper code to load data from input file (generated using JNI) into vector/array. } void SaveDataToFile() { // TODO: Write proper code to store vector/array to file. } void DisplayMenu() { // TODO: write proper code to display menu to user to select from } int main() { GenerateData(); return 1; } //////ZooFileWriter.java import java.io.FileWriter; import java.io. BufferedReader; import java.io.InputStreamReader; public class ZooFileWriter { public static String padleft(String str, int leng, String stringpadval) { for (int i = str.length(); i

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions