Question: This exercise has two classes. The first class is named ObjectsToArrayList . The second class is called just Objects . Your responsibility is to create

This exercise has two classes. The first class is named ObjectsToArrayList. The second class is called just Objects. Your responsibility is to create the Object class and become familiar with how the ObjectsToArrayList class works. Requirements for the Object Class. 2 data fields: int obj_id, String obj_name. 2 Constructors: No-Arg and one that takes both values and assigns them to the data field. Gets and sets for both data fields A toString() method that returns output like: The object ID is 22 and the name is Andrea The ObjectsToArraylist class will create an ArrayList of objects. It will ask for and populate the data fields of an Object, then add it to the ArrayList. This can be done for as many instances of the Object that the user wants to enter. Again, this code is already supplied. Example Output The object ID is 22 and the name is Andrea The object ID is 45 and the name is Rabini The object ID is 21 and the name is Anderson The object ID is 56 and the name is Thomas

What I have so far:

import java.util.*; /** * * @author Student */ public class ObjectsToArrayList {

public static void main(String[] args) { Scanner input = new Scanner(System.in); ArrayList objectList = new ArrayList(); System.out.println("Please enter information for your favorite object!"); do { // collect an indicator to determine the method to call Object object = new Object(); System.out.println("Enter a whole number for the ID of your object: " + "or enter 99 to quit."); int tmpInt = input.nextInt(); // if 99 is entered exit the loop. if (tmpInt == 99) { break; } object.setObj_id(tmpInt); input.nextLine(); // ask for the Object Name System.out.println("Please enter the name of the Object:"); object.setObj_name(input.nextLine()); objectList.add(object);

} while (true); // this is a contineous loop if the break isn't included. for(Object object:objectList) { System.out.println(object.toString()); } } }

//**************************************************** //**** Objects Class is below this block ** //****************************************************

class Object {

// enter object code here }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!