Question
TheZoo.cpp ============================================= #include #include using namespace std; void GenerateData() //DO NOT TOUCH CODE IN THIS METHOD { JavaVM *jvm; // Pointer to the JVM (Java
TheZoo.cpp
=============================================
#include
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) & 0x0f)
jclass cls2 = env->FindClass("ZooFileWriter"); // try to find the class if (cls2 == nullptr) { cerr GetStaticMethodID(cls2, "createZooFile", "()V"); // find method if (mid == nullptr) cerr CallStaticVoidMethod(cls2, mid); // call method cout
jvm->DestroyJavaVM(); 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
public static String padRight(String str, int leng, String stringpadVal) { for (int i = str.length(); i
}
Wildlife Zoo CS 210 Wildlife Zoo Interface Guide 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: i. Track #: 6 characters ii. Name: 15 characters iii. Type: 15 characters iv. Sub-type: 15 characters V. Eggs: Integer vi. Nurse: Integer 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 (egg laying) or Mammal (primarily non-egg laying) Sub-type: Crocodile, Bat, Whale, and so on Eggs: 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. Wildlife Zoo Nurse Eggs 2 0 O 1 Track # 000001 000002 000003 000004 000005 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 1 1 0 0 1 10 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 + name: string + Track Num: Integer Oviparous Mammal NumberOfERES + Nurse 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). Wildlife Zoo 5. 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 "Track#" when the user selects the "Delete Record" option from the menu. i. 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 finishedStep 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