Add 2 more Camel objects, but this time ask the user for inputting all the values and
Fantastic news! We've Found the answer you've been seeking!
Question:
Add 2 more Camel objects, but this time ask the user for inputting all the values and then print the info
using the getInfo method.
/Class Declaration
public class Camel
{
// Instance Variables
int ID;
String name;
int age;
String color;
// method 1
public String getInfo() {
return ("ID of this Camel is: "+ID+" and the name is: "
+ name+".\n It is "+ age + " years old and its color is: " +
color);
}
public static void main(String[] args) {
Camel c1 = new Camel();
c1.ID="379";
c1.name= "The Red One";
c1.age=7;
c1.color="Brown Red";
System.out.println(c1.getInfo());
}
}
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date: