java - How to manipulate variables in deep class -
I just started learning Java and I think this is a very basic question but I do not have the right answer yet. Found, so I try here.
I want to show the names and details of some animals in my console, but I do not know how to manipulate the variables from any class of the class.
I think that I have to use parameters but I do not know how to use them in class ...
My "Animals."
public class animal {private string name; Public stable string description; Public string toasting () {return "jay needle" + this.nom; } Public Zero Diary () {System.out.println (toString ()); } Public Zero direDESCRIPTION () {System.out.println ("Description:" + this.DESCRIPTION); } Public string getNom () {return name; } Public Zero SatName (string name) {this.nom = nom; } Class vertebra {int nbr vertébre Class Memfefer {Class Our (string name = "Pomba" String description = "Description" Poumba ";} class Cimpanj {string name =" Chita "; String description =" Description de cheetah ";} class mice {string name =" Rtta "string description =" Description of the details ";}} class Poson {square Requins {string nom =" Jaws "; string description =" Description de Jose ";} class Raies {string nom =" Raimonta "; string description = "Description raimonta";} class trivial [string name = "truitta"; string description = "description de tr Uita ";}} class reptiles {square Tortue {String nom =" Tortega "; String description =" Description The Tortega ";} class snake {string name =" Srpenta "String description =" Description de Srpenta ";}}} }}
My "testzoo.java"
public class TestZoo {public static void main (string [] Arges) {animal Anaiml = new animal ( ); unAnimal.setNom ( "Jaws"); unAnimal.direNom (); unAnimal.direDESCRIPTION (); unAnimal.setNom ( "leopard"); unAnimal.direNom (); unAnimal.direDESCRIPTION (); unAnimal.setNom ( "Ham "); UnAnimal.direNom (); UnAnimal.direDESCRIPTION (); }}
Try it:
import java .util *. Import java.lang *; Import java.io * *; Square iodogon {public static zero main (string [] args) {our pubba = new our (); Poumba.direNom (); }} Class animal {protected string name; Public string toastring () {return "jay suis" + this.nom + ", which suits un" + this.getClass (); } Public Zero Diary () {System.out.println (toString ()); } Public string getNom () {return name; } Public Zero SatName (string name) {this.nom = nom; }} Square Vertébé Animal Expansion {int nbrVertebre; } Class mempherere extends class {} class of our extension {our public} (this expands the "Poumba");}}
Comments
Post a Comment