1 //设计一个学生类 属性有姓名学号 可以给姓名 和学号赋值 可以显示学生的姓名和学号 2 #include <iostream> 3 #include<string> 4 using namespace std; 5 6 //学生类 7 class Student 8 { 9 public: //公共权限 10 //类中的属性和行为 我们统一成为 成员 11 12 //属性 成员属性 成员变量 13 14 //行为 成员函数 成员方法 15 16 //属性 17 string…
#29.编写一个Java应用程序,设计一个汽车类Vehicle,包含的属性有车轮个数 wheels和车重weight.小车类Car是Vehicle的子类,其中包含的属性有载人数 loader.卡车类Truck是Car类的子类,其中包含的属性有载重量payload.每个 类都有构造方法和输出相关数据的方法.最后,写一个测试类来测试这些类的功 能. package hanqi; public class Vehicle { private int wheels; private int weight…
要求:设计一个字符串类String,可以求字符串长度,可以连接两个串(如,s1=“计算机”,s2=“软件”,s1与s2连接得到“计算机软件”),并且重载“=”运算符进行字符串赋值,编写主程序实现:s1="计算机科学",s2=“是发展最快的科学!”,求s1和s2的串长,连接s1和s2 #include "stdafx.h" #include <iostream> #include <string> using namespace std; cl…
1 源文件 main.cpp 2 //点和圆的关系 3 //设计一个圆形类 和一个点类 计算点和圆的关系 4 //点到圆心的距离 == 半径 点在圆上 5 //点到圆心的距离 > 半径 点在圆外 6 //点到圆心的距离 < 半径 点在圆内 7 //点到圆心的距离 获取 ....... (x1 -x2)^2 + (y1-y2)^2 开根号 和半径对比 8 // 计算 可以 两边同时 平方 9 #include <iostream> 10 #include<string>…
1 //点和圆的关系 2 //设计一个圆形类 和一个点类 计算点和圆的关系 3 //点到圆心的距离 == 半径 点在圆上 4 //点到圆心的距离 > 半径 点在圆外 5 //点到圆心的距离 < 半径 点在圆内 6 //点到圆心的距离 获取 ....... (x1 -x2)^2 + (y1-y2)^2 开根号 和半径对比 7 // 计算 可以 两边同时 平方 8 #include <iostream> 9 #include<string> 10 #include"…
package car; public class Vehicle { //定义成员变量 private int wheels; private double weight; public int getWheels() { return wheels; } public void setWheels(int wheels) { this.wheels = wheels; } public double getWeight() { return weight; } public void set…
import java.util.*; import java.lang.Math; class Date1{ private int year; private int month; private int day; Date1(){ year=1900; month=1; day=1; } Date1(int y,int m,int d){ this.year=y; this.month=m; this.day=d; } public int getYear(){ return year;…
package b; public interface Computer { int computer(int n,int m); } package b; public class Jia implements Computer { @Override public int computer(int n, int m) { int jia; jia=m+n; System.out.println(m+"+"+n+"="+jia); return jia; } }…
package Test; public class test6 { public static void main(String[] args) { // TODO Auto-generated method stub Mypoint mypoint1 = new Mypoint(1,1); Mypoint mypoint2 = new Mypoint(2,2); double distance = Mypoint.getDistance(mypoint1, mypoint2); System…