quinta-feira, 4 de maio de 2017

codigo 04.05.2017 turma 2

//*******************************************************************
// Dear CompileJava users,
//
// CompileJava has been operating since 2013 completely free. If you
// find this site useful, or would otherwise like to contribute, then
// please consider a donation (link in 'More Info' tab) to support
// development of the new CompileJava website (stay tuned!).
//
// Most sincerely, Z.
//*******************************************************************

import java.lang.Math; // headers MUST be above the first class

// one class needs to have a main() method
public class HelloWorld
{
  // arguments are passed using the text field below this editor
  public static void main(String[] args)
  {
    OtherClass myObject = new OtherClass("Hello World!");
    System.out.print(myObject);
    System.out.println (myObject.message);
    
    Batata b = new Batata();
    System.out.println (b.retornaConteudo().message);
    System.out.println (b.retornaS());
    
    MeuObjeto meuObjeto = new MeuObjeto();
  }
}

class MeuObjeto {
  // atributos 
  // metodos
}


public class Batata {
    OtherClass o = new OtherClass ("Batata");
  OtherClass retornaConteudo () {
    return o;
  }
  String retornaS () {
    return o.toString();
  }

}
// you can add other public classes to this editor in any order
public class OtherClass
{
  public String message;
  private boolean answer = false;
  public OtherClass(String input)
  {
    message = "Why, " + input + " Isn't this something?";
    //return message;
  }
  public String toString()
  {
    return message;
  }
}

Nenhum comentário:

Postar um comentário