java父类子类代码

import java.util.Scanner;
import java.util.*;
class PersonF
{
public void print(String ID,String Workcard,String name,char fig,int age,String pro)
{
System.out.printf("%s %s %s %c %d %s ",ID,Workcard,name,fig,age,pro);
}
}
class Student extends PersonF
{
public void print1(int score1,int score2,int score3)
{
System.out.printf("%d %d %d",score1,score2,score3);
}
}
class teacher extends PersonF
{
public void print2(String kk,int time)
{
System.out.printf("%s %d",kk,time);
}
}
public class Main {

public static void main(String[] args)
{
PersonSon p=new Student();
PersonSon p1=new teacher();
Student s=new Student();
teacher t=new teacher();
Scanner AI=new Scanner(System.in);
String ID;String Workcard;String name;char fig;int age;String pro;
int score1;int score2;int score3;
String kk;int time;
int count;
while(AI.hasNext())
{
count=AI.nextInt();
if(count==1)
{
//System.out.print(count);
ID=AI.next();
//System.out.print(ID);
Workcard=AI.next();
//System.out.print(Workcard);
name=AI.next();
//System.out.print(name);
fig=AI.next().charAt(0);
//System.out.print(fig);
age=AI.nextInt();
//System.out.print(age);
pro=AI.next();
//System.out.print(pro);
score1=AI.nextInt();
score2=AI.nextInt();
score3=AI.nextInt();
System.out.printf("Student:");
s.print(ID, Workcard, name, fig, age, pro);
s.print1(score1, score2, score3);
System.out.println();

}
if(count==2)
{
ID=AI.next();
Workcard=AI.next();
name=AI.next();
fig=AI.next().charAt(0);
age=AI.nextInt();
pro=AI.next();
kk=AI.next();
time=AI.nextInt();
System.out.printf("Teacher:");
t.print(ID, Workcard, name, fig, age, pro);
t.print2(kk, time);
System.out.println();
}
}
}

}

转载于:https://www.cnblogs.com/AIERSTOM/p/AIERSTOM1001.html

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值