sytn.net
当前位置:首页 >> 用jAvA编写两个类,pErson和stuDEnt, PErson类有三... >>

用jAvA编写两个类,pErson和stuDEnt, PErson类有三...

//第一个类package com.openwan.util;public class Person { private String name; private String sex; private int age; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getSex() { return sex; }

class student extends person{}

c++语言 class person{ public: //构造方法初始化 void InitP(string Name,string Sex,int Age){ name=Name; sex=Sex; age=Age; }; //显示信息 void showme(){ cout<<"Name:"<<name<<"Sex:"<<sex<<"Age:"<<age; }; string GetName(){

public class Person{ protected String name; public Person(){ } public Person(String name){ this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; }}class Student extends Person{ private

Person.java public class Person { private String name; private String address; private int phoneNumber; private String email; public Person(String name, String address, int phoneNumber, String email) { this.name = name; this.address = address;

你好!是c其他不用说a 是父类对象指向子类对象实例的引用.是可以的.如果对你有帮助,望采纳.

public class Person{ public String name; public char sex; public int age; } public class Student extends Person{ public long number; public int phi; public int eng; public int comp; public double aver(){ return (phi+eng+comp)/3; } public int max(){ return

public class Person { String name; int age; int number; Person() { name=""; age=0; number=0; } Person(String name,int age,int number) { =name; e=age; mber=number; }

//person类class person{string name; //person类的属性char sex;int age;}//学生类继承父类personpublic class student extends person{ public student(string n,char s,int a){ super(n,s,a);} //主方法public static void main(string adfaf[]){student s[]=new

public abstract class Person { public String name; public String sex; public int age; public void eat(){} public void talk(){} } public class Student extends Person{ } public class Worker extends Person{ } 手敲的,可能有点小错,绝对不影响 person类还

相关文档
网站首页 | 网站地图
All rights reserved Powered by www.sytn.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com