Within this program I am creating an class instance.
I am trying to make a void method to display the person’s (objects) attributes outside of the main method.
The errors are:
1.‘No field name size was found in People‘ (5)
2.‘No method called DisplayAtt was found in People‘ (20)
Im wondering if this is an error asociated with my program or the general syntax of RTP.
I am trying to learn OOP.
class People
{
public void DisplayAtt ()
{
System.out.println (size);
System.out.println (race);
System.out.println (personality);
}
public static void main (String args[])
{
Person thisPerson;
thisPerson = new Person ();
thisPerson.size = "Average";
thisPerson.race = "Caucasian";
thisPerson.personality = "Stubborn";
thisPerson.DisplayAtt ();
}
}
/// Object Class ///
public class Person
{
String size;
String race;
String personality;
}
The display att needs to be a method in your Person class or needs to accept a person as aparameter.