渡す引数が異なる同じメソッドを作ろうとしているのですが、なかなかうまくいきません。
以前質問したものを参考にしているのですが、、、
https://teratail.com/questions/55604
どこを修正すれば良いでしょうか?
java
1package com.example.macpro_n_goto.test20161113_gamennseni.databases; 2 3import android.support.v7.app.AppCompatActivity; 4 5/** 6 * Created by MacPRO-N-GOTO on 2016/11/19. 7 */ 8 9public class TestOya extends AppCompatActivity{ 10 11 public String name; 12 public int birthday; 13 public int manpukudo; 14 15 public TestOya(String name,int bir,int man){ 16TestOya(name,bir,man); 17 this.name = name; 18 this.birthday = bir; 19 this.manpukudo = man; 20 } 21 22 public TestOya(String name,int bir){ 23 TestOya(name,bir,null); 24 this.name = name; 25 this.birthday = bir; 26 } 27 28 public TestOya(String name){ 29 TestOya(name,null,null); 30 this.name = name; 31 } 32 33 public void eat(){ 34 this.manpukudo += 60; 35 } 36 37} 38
java
1package com.example.macpro_n_goto.test20161113_gamennseni; 2 3import android.content.Intent; 4import android.os.Bundle; 5import android.support.v7.app.AppCompatActivity; 6import android.view.View; 7 8import com.example.macpro_n_goto.test20161113_gamennseni.databases.TestOya; 9 10 11public class MainActivity extends TestOya { 12 13 14 @Override 15 protected void onCreate(Bundle savedInstanceState) { 16 super.onCreate(savedInstanceState); 17 18 TestOya test = new TestOya("山田"); 19 20 //test.eat(); 21 22 System.out.println("名前:" + test.name); 23 System.out.println("生年月日:" + test.birthday); 24 System.out.println("満腹度:" + test.manpukudo); 25 26 System.out.println("Aのオンクリエイトが呼ばれました"); 27 28 setContentView(R.layout.activity_main); 29 30 31 //次ページボタンを取得 32 findViewById(R.id.button1).setOnClickListener(new View.OnClickListener() { 33 34 //次ページボタンが押されたときの処理 35 @Override 36 public void onClick(View v) { 37 38 //intent生成 39 Intent intent = new Intent(getApplication(),SecondActivity.class); 40 41 String str = "テスト"; 42 intent.putExtra("str", str); 43 44 //SecondActivityに遷移 45 startActivity(intent); 46 } 47 }); 48 } 49 50 @Override 51 public void onStart(){ 52 super.onStart(); 53 System.out.println("Aのオンスタートが呼ばれました"); 54 } 55 56 @Override 57 public void onResume(){ 58 super.onResume(); 59 System.out.println("Aのオンレジュメが呼ばれました"); 60 } 61 62 @Override 63 public void onPause(){ 64 super.onPause(); 65 System.out.println("Aのオンポーズが呼ばれました"); 66 } 67 68 @Override 69 public void onRestart(){ 70 super.onRestart(); 71 System.out.println("Aのオンリスタートが呼ばれました"); 72 } 73 74 @Override 75 public void onStop(){ 76 super.onStop(); 77 System.out.println("Aのオンストップが呼ばれました"); 78 } 79 80 @Override 81 public void onDestroy(){ 82 super.onDestroy(); 83 System.out.println("Aのオンディストリーが呼ばれました"); 84 } 85} 86
追記
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/11/18 18:10
2016/11/18 18:11
2016/11/18 18:13
2016/11/18 18:17
2016/11/18 18:26