将「南通渡课 IT 教育 111 班同学在 3 教室上崔老师的 Java 课」这个场景进行业务类的抽象,类中包含属性和方法。

编程入门 行业动态 更新时间:2024-10-25 08:22:21

将「<a href=https://www.elefans.com/category/jswz/34/1769533.html style=南通渡课 IT 教育 111 班同学在 3 教室上崔老师的 Java 课」这个场景进行业务类的抽象,类中包含属性和方法。"/>

将「南通渡课 IT 教育 111 班同学在 3 教室上崔老师的 Java 课」这个场景进行业务类的抽象,类中包含属性和方法。

从中抽象出来的类

1.学校
2.同学
3.教室
4.老师
5.课程

1.学校类

public class School {
// 成员变量
String name;
int tel;
String address;
// 构造器
School(String name, int tel, String address) {
this.name = name;
this.tel = tel;
this.address = address;
}
// 方法
String intro() {
return “这个学校名称是”+this.name+",联系电话是"+this.tel+",地址为"+this.address;
}
}

2.同学类

public class Classmate{
//成员变量
String name;
String code;
int age;

//构造器
Classmate(String name, String code, int age){
this.name=name;
this.code=code;
this.age=age;
//方法
String intro() {
return “我叫”+this.name+",我的学号是"+this.code+",我今年"+this.age+“岁了。”;
}
}

3.教室类

public class Classroom {
// 成员变量
String name;
double size;
String color;
//构造器
Classroom(String name, double size, String color) {
this.name = name;
this.size = size;
this.color=color;
}
// 方法
String intro() {
return “教室名”+this.name+",教室座位数"+this.number;
}
}

4.老师类

public class Teacher {
// 成员变量
String name;
int age;
String code;
//构造器
Teacher(String name, int age, String code) {
this.name = name;
this.age = age;
this.code = code;
}
// 方法
String intro() {
return “老师叫”+this.name+",老师的编号是"+this.code+",老师今年"+this.age+“岁了。”;
}
}

5.课程类

public class Course {
// 成员变量
String name;
int code;
//构造器
Course(String name, int code) {
this.name = name;
}
// 方法
String intro() {
return “课程名”+this.name;
}
}

更多推荐

将「南通渡课 IT 教育 111 班同学在 3 教室上崔老师的 Java 课」这个场景进行业务类的抽象,类中包含属性和方法。

本文发布于:2024-03-13 03:01:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1733040.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:南通   抽象   类中   属性   场景

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!