What a constructor do ?

Hum.. I always forget the function of a constructor because I don’t have the custom to use.

For this reason, I will put here some tips:

A constructor  is a method with instructions that will execute ALWAYS  when will instantiated a object of this class.

Like this:

  • Class MyClass.java
 public class MyClass {

public MyClass() { //this is the constructor method
System.out.println(“Hello World !”);
}  }

In the constructor method will be wrrte “Hello World !”

So… when you call this class, the constructor will be execute.

 

  • Class Test.java
 public class Test {

public static void main(String args[]) {
MyClass Obj1 = new MyClass();
}
}

It’s simple no ? It is just a method that will be execute before others methods when you call this class.
Bye bye !

The best small caps in March

Sao Paulo – With changes in index of small caps of Bovespa, the compiled of stocks more recommended made by InfoMoney shows a different result  of last month. In the third month of 2013, the America Latina Logistica (ALLL3), wich not was in the february index, is in the first position with six votes between 25 of analysed portfolio.

The second place was with Anhanguera (AEDU3), wich was recommended in five of 25 analysed portfolio. The third place was divided between the companies Even (EVEN3) and PDG Realty (PDGR3), wich were cited three times each.

 

Others recommendations:

Alpargatas (ALPA4), Eztec (EZTC3), Grendene (GRND3), Iguatemi (IGTA3), Kroton (KROT3), Marfrig (MRFG3), Iochp-Maxion (MYPK3), Marcopolo (POMO4), Randon (RAPT4), São Martinho (SMTO3), V-Agro (VAGR3) e Valid (VLID3).

 

With one vote each, close the list of recommendations the papers of  Aliansce (ALSC3), Lojas Marisa (AMAR3), Banrisul (BRSR6), Equatorial (EQTL3), Fleury (FLRY3), Gafisa (GFSA3), Helbor (HBOR3), Metal Leve (LEVE3), Le Lis Blanc (LLIS3), Magnesita (MAGG3), Mils (MILS3), MRV (MRVE3), Odontoprev (ODPV3), Paranapanema (PMAM3), Qualicorp (QUAL3), Rossi Residencial (RSID3), SierraBrasil (SSBR3) e Santos BRP (STBP11).

 

Font: http://www.infomoney.com.br/onde-investir/acoes/noticia/2697172/small-caps-mais-recomendadas-para-marco-por-corretoras

How can I call the drivers(browsers) in Selenium with java ?

It’s simple !

you have to call the import > import org.openqa.selenium.WebDriver; and others about the browsers, like: import org.openqa.selenium.firefox.FirefoxDriver; (calls Firefox)

After this, in the class Main, declare driver:

WebDriver driver;

and Quit:

Quit quit = new Quit();

So… you have now choose what is the browser and calls the profile and set the configs, like proxy (for this reason you have to create a profile)

public class Main {

public static void main(String[] args) throws Exception {

FirefoxProfile profile = new FirefoxProfile();   // create a profile of Firefox
profile.setPreference(“network.proxy.type”, 0);   // Don’t use proxy
driver = new FirefoxDriver(profile);       // calls the browser with the configs of the profile
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);     // config the timeouts for load a page
driver.get(site);     // change site for the url that your driver will open.

quit.tearDown(driver);     // quit the driver.

}

}

You have to create the class that close the driver in class Main.

public class Main {

public static class Quit {

public void tearDown(WebDriver driver) {
driver.close();
driver.quit();
}

}

and finish !

This is the first step for create a automation with selenium. Create a driver and open the browser !

Good studies for all, bye !

Inherit with java

You can do the class inherit other like this: 

class NomeDaClasseASerCriada extends NomeDaClasseASerHerdada

We show an sample:

Class 1: Eletrodomestico

package tiexpert;

public class Eletrodomestico {
private boolean ligado;
private int voltagem;
private int consumo;
public Eletrodomestico(boolean ligado, int voltagem, int consumo) {
  this.ligado = ligado;
  this.voltagem = voltagem;
  this.consumo = consumo;
  }
// (...)
}
Class 2: TV
package tiexpert;

public class TV extends Eletrodomestico {
private int canal;
private int volume;
private int tamanho;
public TV(int voltagem, int consumo, int canal, int volume, int tamanho) {
  super(false, voltagem, consumo);
  this.canal = canal;
  this.volume = volume;
  this.tamanho = tamanho;
 }
 //(...)
}
Instance:
package tiexpert;

public class ExemploHeranca {
  public static void mostrarCaracteristicas(TV obj) {
   System.out.print("Esta TV tem as seguintes características:\n"
   + "Tamanho: " + obj.getTamanho() + "\"\n"
   + "Voltagem Atual: "+ obj.getVoltagem() + "V\n"
   + "Consumo/h: " + obj.getConsumo() + "W\n");
   if (obj.isLigado()) {
    System.out.println("Ligado: Sim\n"
   + "Canal: " + obj.getCanal() + "\n"
   + "Volume: " + obj.getVolume()+"\n");
   } else {
  System.out.println("Ligado: Não\n");
 }
}
public static void main(String args[]) {
  TV tv1 = new TV(110950021);
  TV tv2 = new TV(2201270029);
  tv2.setLigado(true);
  tv2.setCanal(3);
  tv2.setVolume(25);
  mostrarCaracteristicas(tv1);
  mostrarCaracteristicas(tv2);
 }
}
Let’s trainning !!
Font: http://www.tiexpert.net/programacao/java/heranca.php

How we can find a line in some table with Webdriver (Selenium) ?

Hi guys, I’m very occupied in the last months, but I will post a text about catch the lines and values in some table with Webdriver (selenium) in language java. Yes, I am changing a little the subjects, this time I will help the testers, who do automation of sites.

It’s easy if you use XPath.

This table:

Apples 44%
Bananas 23%
Oranges 13%
Other 10%

/html/body/div[1]/div/div[4]/div[2]/div[2]/table/tbody/tr[1]

You catched the first line.

If you want catch the second line, just change the number:

/html/body/div[1]/div/div[4]/div[2]/div[2]/table/tbody/tr[2]

It’s more easy than you expected, not ?

if you want catch all the text of all lines, just write the code:

WebElement listatable = driver.findElement(By.className(“reference”));

for (int i = 0; i < listatable.getLength(); i++) {

WebElement line = driver.findElement(By.xpath(“/html/body/div[1]/div/div[4]/div[2]/div[2]/table/tbody/tr[” + i + “]”));

line.getText();

}

Fine, now you can catch the text of each line in this table !

I hope has helped the initial testers in something.

Bye bye !

Polymorphism – C#

What is ?

It let invoke methods of the class through of a reference class base during a run-time. This is useful when you have a array and you have to invoke each method of him. they don’t need be the same type of the object.

using System;

public class DrawingObject
{
public virtual void Draw();
{
Console.WriteLine(“I’m just a generic drawing object.”);
}
}

This will be the base for others objects of classes inherit. The method Draw() performs the only action of print the declaration.

using System;

public class Line : DrawingObject
{
public override void Draw();
{
Console.WriteLine(“I’m a Line.”);
}
}

public class Circle : DrawingObject
{
public override void Draw()
{
Console.WriteLine(“I’m a Circle.”);
}
}

public class Square : DrawingObject
{
public override void Draw()
{
Console.WriteLine(“I’m a Square.”);
}

}

Show 3 classes, and this classes are inherited the DrawingObject. Each class have a method Draw() and each Draw() have a modifier override.

using System;

public class DrawDemo
{
public static int Main( )
{
DrawingObject[] dObj = new DrawingObject[4];

dObj[0] = new Line();
dObj[1] = new Circle();
dObj[2] = new Square();
dObj[3] = new DrawingObject();

foreach (DrawingObject drawObj in dObj)
{
drawObj.Draw();
}

return 0;
}

}

This program implements polimorphism. In the method Main() of class DrawDemo, there is a range wich are being created. The type of the object in this matrix is a DrawingObject class. The matrix is called dObj and is being initialized for stop four objects of type DrawingObject.

Output:

I’m a Line.
I’m a Circle.
I’m a Square.

I’m just a generic drawing object.

The override method Draw() of each derived performs how shown on the program DrawDemo. The las line is starting of virtual Draw() DrawingObject method of the class. This, because the real run-time type of fourth element was an array DrawingObject object.

So, this is only a summary about polimorphism in C#. Hope this help every one to start use this resource.

Font: http://www.oficinadanet.com.br/artigo/885/curso_de_c_sharp_licao_9_polimorfismo

I sold my property and I will pay rent

Hello again, I found a news about the last subject. For this reason I translated a little bit of the text…

Change own property by itself to take advantage of high prices is a decision that involves significant changes in personal finances.Reporting by Luciana Seabra, Valor, took up in detail of the subject and told how two couples decided to give up the security of their own home to live paying rent. And how are they doing to manage the anxiety of having to invest large amount of funds received after the sale of the property and simultaneously follow the evolution of the property market.

[…]

Firstly, it is important consider that rents are adjusted annually for inflation and this way should be the concerned with preserving the purchasing power of the value of the application. One problem is that the standard adjustment of rents is the IGP-M, but it is not common find investments corrected by this index.

The best solution, then is invest in securities adjusted by the IPCA, considering that in the long term the trend is that all inflation indices have similar variation.

The second equally important factor is the solidness of the investment, especially considering that the amounts involved are high and the fact that, generally, the property where the couple lives represents a high fraction of the total richness of the family.

Change the security of the own property by income from financial investments, it is necessary that the investment has the least possible chance of suffer some sort of indebtedness. The safest option is government bonds.

The third point for to consider is the need for periodic liquidity for a small part of the total application. That’s because you need to use part incomes for pay the rent and the best alternative to fill this requirement are the roles that pay regular income every six months.

Finally, the ideal is that the application is long-term, to reduce the risk that the premises which were used to support the decision to sell for rent change drastically.

An investment option that combines all the features above is the NTN-B with maturity in 2045 traded at Treasury Direct.

[…]

And I hope this text can helps you, like me. Because I always thought that the NTN-F with maturity in 07.01.17 would the better choice.

Font: http://www.valor.com.br/valor-investe/o-consultor-financeiro/2551514/vendi-meu-imovel-e-vou-pagar-aluguel

What is more gainful ? Rent or buy a house ?

Hello everybody !

A long time that I don’t post anything. I’m so sorry I was very occupied in last month, I changed my job and I was in exams period.

So.. I read a book the title is “Smart Couples enrich together”, it’s about where and when you and your husband/boyfriend should invest for win more interest.

In first example, if you have a lot of money like $100,000 in some fund that gives you a interest rate of 1.0%, you will receive $1,000 of interest, and this number will grow up because it is interest above interest and amount.

Yes in this case, you can choose what is better for you and your plan, because you can pay the rent of a house with interest and continue saving money and your amount +  interest will continue grow up, in the future you can buy a biggest house, or go to travel, or retire yourself and don’t work anymore.

If you think in buy some house and rent, you have to think what is more gainful. When you rent a house if the price of the house is $100,000, you will retrieve something about $800, and you have to remember that you have to pay the income taxes.

So, if you save the money in some fund that gives a interest of 1.0% is more gainful that you buy a house and rent it.

It’s a simple example, but helped me a lot in a decision of buy a house or rent one. I will search some fund that gives me a better interest rate and how I don’t have hurry for live alone, I will let the money to yield for me more money.

Goodbye ! I hope this tip helps everyone !

The Retirement Savings Move Tax Pros Love

This is a small part of the Bloomberg’s new. Take a look !

When it comes to saving for his own retirement, certified public accountant Barry Picker takes advantage of a tax strategy ignored by most Americans. Each year he stashes some of his retirement savings in a Roth 401(k), rather than putting all his savings into a traditional 401(k).

While that means he misses out on the immediate tax break that comes from contributing to a traditional 401(k), Picker has something else in mind — a less taxing retirement. By paying taxes now, he won’t have to worry about paying taxes when he withdraws money from his Roth 401(k) later. Money withdrawn from a traditional 401(k), of course, will be taxed as ordinary income.

 The big question investors have to grapple with, of course, is why they would rather pay taxes now instead of later — especially when there is no way to know where tax rates will be in the future. “It’s a compromise,” says Picker, who is also a certified financial planner. “I am giving up some control over managing my tax bracket today for being able to manage it in retirement. That’s going to be valuable to me later.”

 

Social Security and Medicare

While Picker is thinking about keeping his taxes down in retirement, a Roth 401(k) also provides more flexibility when it comes to managing income and some less obvious payoffs as well. A traditional 401(k) requires you to begin taking distributions in the year your turn age 70½ (or if later, the year you retire) — and then you pay taxes on that income. With the Roth 401(k), there is no required minimum distribution (if you roll the Roth 401(k) into a Roth IRA). That means you can choose to leave your funds invested and reduce your gross income.

To continue reading, click on the link below.

Font: http://www.bloomberg.com/news/2012-06-04/the-retirement-savings-move-tax-pros-love.html