H rngM

// IGraph.java public interface IGraph { void draw(); void paint();

- ' Android g^ffift OnClickListener ^ffi '

Android JSfflfM^fif :

//Android MMfM^ ■' MyActivity.java public class MyActivity extends Activity implements OnClickListener { /** Called when the activity is first created. */ private final int DB_Version = 1; private final int DB_Mode = ContextMODEPRIVATE; private final int WC = ViewGroup.LayoutParams. WRAPCONTENT; private SQLiteDatabase db=null; private Button btn;

@Override public void onCreate(Bundle icicle) { super. onCreate(icicle); btn = new Button(this); btn.setText("Exit"); btn.setOnClickListener(this);

setContentView(btn, new LinearLayout.LayoutParams(WC, WC)); try { db = createDatabase("MyDB", DB_Version, DB_Mode, null); } catch(FileNotFoundException e){

if (db != null) setTitle("create DB OK!"); else setTitle("Error!");

public void onClick(View v){

ö^Affisrnwassu'm^mmm^mmm^mm^m^mmprnm

// EX03 09 package _objects;

public class Afi //®^AstAiß« { private String Name;

public float ComputeTuition(int credit) { if (credit > 6) credit = 6; return (credit -1) * 500 + 5000;

// BasicFee.java package _objects;

public float ComputeTuition(int credit) { if (credit > 6) credit = 6;

ComputeTuition()®MAff^AAPA^W^AÖW^ ° ' MM rüj AMAiT^Affi ° ^A^AMMffiS^ ' *

ffl rAPAj SMMA (credit-1)*500

m rW^ij SMMA credit *700

Mlxff^ffi Overridable : GetValueOffiaSMiiÄA ' OTÄfflSIÄ .

rnmrn ComputeTuitionO^AMfSaSA ' mTMA =

// EX03 10 package _student; import _interface.*;

public class PA {

private String Name; public float ComputeTuition(int credit) { if (credit > 6) credit = 6; return tc.GetValue(credit) + 5000;

protected abstract float GetValue(int credit);

public float GetValue(int credit) { return (credit -1) * 500; }

public float GetValue(int credit) { return credit * 700; }

// EX03 11 package _interface;

public interface ITuition //PSA® { public float GetValue(int credit); }

package _student; import _interface.*; public class PA {

private String Name; private ITuition tc;

public void Setter(ITuition tuiObj) { tc = tuiObj; } public float ComputeTuition(int credit) { if (credit > 6) credit = 6; return tc.GetValue(credit) + 5000;

package _tuition_plugin; import _interface.*;

public class APAPS implements ITuition {

public float GetValue(int credit) { return (credit -1) * 500; }

public class WAXPS implements ITuition { //$PH^iA

public float GetValue(int credit) { return credit * 700; }

ITuition ^ffi . ^gfgf rP^j ^fr® rAf4ffj ^ ^m^M^if^MfM^ ' JMain :

import _student.*; import _tuition_plugin.*; public class JMain {

public static void main(String[] args) { float t1, t2;

Lily.Setter(under_tui);

t1 = Lily.ComputeTuition(5);

grad_tui = new Peter.Setter(grad_tui); t2 = Peter.ComputeTuition(7);

System.out.println( "Lily: " + String.valueOf(tl) + ", Peter: "

ftg^^^mAP^ Lily fPW^ Peter Lily: 7000, Peter: 9200 +

Android '

Android MfflflA 0

MfiAu&xrnmrnrnm »

0 0

Post a comment