大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
public class $ {
为宁城等地区用户提供了全套网页设计制作服务,及宁城网站建设行业解决方案。主营业务为网站制作、网站设计、宁城网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
public static void main(String[] args) {
Glede glede = new Glede("老鹰");
glede.sound();
System.out.println("最大飞行速度:" + glede.flySpeed());
Pigeon pigeon = new Pigeon("鸽子");
pigeon.sound();
System.out.println("最大飞行速度:" + pigeon.flySpeed());
}
}
abstract class Animal {
private String type;
public Animal(String type) {
this.type = type;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public abstract void sound();
public String toString() {
return type;
}
}
interface Flyable {
double flySpeed();
}
class Glede extends Animal implements Flyable {
public Glede(String type) {
super(type);
}
public double flySpeed() {
return 100;
}
public void sound() {
System.out.println("老鹰叫");
}
}
class Pigeon extends Animal implements Flyable {
public Pigeon(String type) {
super(type);
}
public double flySpeed() {
return 20;
}
public void sound() {
System.out.println("鸽子叫");
}
}
//接口的定义
interface Animal {
public void bark();
public void fly();
}
//老鹰类
class Eagle implements Animal {
public void bark() {
System.out.println("老鹰叫");
}
public void fly() {
System.out.println("老鹰飞");
}
}
//鸽子类
class Pigeon implements Animal{
public void bark() {
System.out.println("鸽子叫");
}
public void fly() {
System.out.println("鸽子飞");
}
}
//测试类
public class Test{
public static void main(String[] args){
Animal pigeon = new Pigeon();
Animal eagle = new Eagle();
pigeon.bark();
pigeon.fly();
eagle.bark();
eagle.fly();
}
}
如果还有什么疑问..请百度Hi我.. 我会进一步的为你解答..
x+y=n
2x+4y=m
得:
x=2n-m/2
y=m/2-n
二元一次方程组 不存在多解
代码如下
import java.util.Scanner;
public class Test {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.println("请输入头的数量");
int n = in.nextInt();
System.out.println("请输入脚的数量");
int m = in.nextInt();
int x = 2*n-m/2;
int y = m/2-n;
if (x + y != n || 2 * x + 4 * y != m) {
System.out.println("error");
} else if (x 0 || y 0) {
System.out.println("error");
} else {
System.out.println(x + " " + y);
}
}
}
abstract class Animal {
private double weight;
abstract void say();
abstract void eat();
public Animal() {
this.weight = 0;
}
public Animal(double weight) {
this.weight = weight;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
}
interface Flyable {
void flySpeed();
}
class Glede extends Animal implements Flyable {
public void flySpeed() {
System.out.println("10m/s");
}
@Override
void say() {
System.out.println("啊啊啊啊");
}
@Override
void eat() {
System.out.println("老鼠");
}
}
class Pigeon extends Animal implements Flyable {
public void flySpeed() {
System.out.println("5m/s");
}
@Override
void say() {
System.out.println("咕咕咕咕");
}
@Override
void eat() {
System.out.println("虫子");
}
}
public class Test {
public static void main(String[] args) {
Glede glede = new Glede();
glede.flySpeed();
glede.say();
glede.eat();
Pigeon pigeon = new Pigeon();
pigeon.flySpeed();
pigeon.say();
pigeon.eat();
}
}