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
} 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
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