Java编程作业,急用

Java编程作业,急用,第1张

public class Pet {

private int weight;

private int age;

private String info;

public int getAge() {

return age;

}

public void setAge(int age) {

thisage = age;

}

public int getWeight() {

return weight;

}

public void setWeight(int weight) {

thisweight = weight;

}

public void showInfo() {

Systemoutprintln(info);

}

public String getInfo() {

return info;

}

}

第二题:

interface Eatable{

public abstract String ebEatted();

}

第三题:

具体代码就不给你写了,思路如下

假设你有一个学生的类student,包涵年龄age,学号,分数count等属性。

把此类实现 Comparable接口,接口有一个方法compareTo

此方法返回一个整数 -1代表小于 1代表大于 0代表等于

比如:

public int compareTo(Student student){

if(thiscount<studentcount)

return -1;

else if(thiscount>studentcount)

return 1;

else

return 0;

}

然后你拿到学生类的集合后,比如一个List<student> students

那么就可以用Collectionssort(students)对这个list进行排序,然后按顺序遍历输出就可以了。

是可以知道的

_IRI 是 Speech Interpretation & Recognition Interface 的首字母缩写,原义为语音识别接口,是苹果公司在iPhone、iPad、iPod Touch、HomePod等产品上应用的一个语音助手,利用Siri用户可以通过手机查找信息、拨打电话、发送信息、获取路线、播放音乐、查找苹果设备等。

_iri可以支持自然语言输入,并且可以调用系统自带的天气预报、日程安排、搜索资料等应用,还能够不断学习新的声音和语调,提供对话式的应答。Siri可以令iPhone4S及以上手机(iPad 3以上平板)变身为一台智能化机器人。

2016年6月13日,在苹果开发者大会WWDC发布了产品Siri的新功能。 [1]

2017年苹果WWDC开发者大会上,Siri的更新当中,加入了实时翻译功能,支持英语、法语、德语等语言,未来将陆续进行支持,与此同时,Siri的智能化还进一步得到提升,支持上下文的预测功能,类似此前发布的谷歌助手,用户甚至可以用Siri作为Apple TV的遥控器。 [2]

2022年2月,抖音搜索与苹果Siri达成合作。

public class User{

int no;

String name;

String gender;

int age;

}

Map<Integer,User> u_map = new HashMap<Integer,User>();

User u = new User(1,"liming","female",19);

u_mapput(1,u);

第一题:

package

text;

/

啮齿动物类,属性有:名字、年龄、是否会飞

@author

Lich

/

public

class

Rodent

{

/

名字

/

private

String

name;

/

年龄

/

private

int

age;

/

是否会飞

/

private

boolean

fly;

/

默认构造函数

/

public

Rodent(){

}

/

带参数的构造方法

@param

name

名字

@param

age

年龄

@param

fly

是否会飞

/

public

Rodent(String

name,int

age,boolean

fly){

thisname

=

name;

thisage

=

age;

thisfly

=

fly;

}

public

void

text(Rodent

rodent){

rodentaction();

}

/

啮齿动物的行为方法

/

public

void

action(){

Systemoutprintln("我会咬东西");

}

/

获取名字

@return

/

public

String

getName()

{

return

name;

}

/

为名字赋值

@param

name

/

public

void

setName(String

name)

{

thisname

=

name;

}

/

获取年龄

@return

/

public

int

getAge()

{

return

age;

}

/

为年龄赋值

@param

age

/

public

void

setAge(int

age)

{

thisage

=

age;

}

/

为是否会飞进行赋值

@return

/

public

boolean

isFly()

{

return

fly;

}

/

获取是否会飞

@param

fly

/

public

void

setFly(boolean

fly)

{

thisfly

=

fly;

}

}

package

text;

/

老鼠类,继承至啮齿动物

@author

Lich

/

public

class

Mouse

extends

Rodent{

/

默认构造方法

/

public

Mouse(){

super();

//调用父类构造方法

}

/

老鼠类带参数构造方法

@param

name

名字

@param

age

年龄

@param

fly

是否会飞

/

public

Mouse(String

name

,

int

age

,

boolean

fly){

super(name,age,fly);//调用父类的带参数的构造方法

}

/

重写父类的行为方法

/

public

void

action(){

Systemoutprintln("我会打洞");

}

}

package comanimaltest;

public class Animal {

private String name;

private int age;

public Animal(String name, int age){

thisname = name;

thisage = age;

}

public String getName() {

return name;

}

public void setName(String name) {

thisname = name;

}

public int getAge() {

return age;

}

public void setAge(int age) {

thisage = age;

}

public void outPut(){

Systemoutprintln("name:"+thisgetName());

Systemoutprintln("age:"+thisgetAge());

}

}

package comanimaltest;

public interface Eattable {

void beatted();

}

package comanimaltest;

public class Bird extends Animal{

private String wing;

private String flyDistance;

public Bird(String name, int age) {

super(name, age);

thiswing = wing;

thisflyDistance = flyDistance;

}

public String getWing() {

return wing;

}

public void setWing(String wing) {

thiswing = wing;

}

public String getFlyDistance() {

return flyDistance;

}

public void setFlyDistance(String flyDistance) {

thisflyDistance = flyDistance;

}

@Override

public void outPut() {

superoutPut();

Systemoutprintln("wing:"+thisgetWing());

Systemoutprintln("flyDistance:"+thisgetFlyDistance());

}

}

package comanimaltest;

public class Beast extends Animal implements Eattable{

private String localPlace;

private String food;

public Beast(String name, int age) {

super(name, age);

thislocalPlace = localPlace;

thisfood = food;

}

public String getLocalPlace() {

return localPlace;

}

public void setLocalPlace(String localPlace) {

thislocalPlace = localPlace;

}

public String getFood() {

return food;

}

public void setFood(String food) {

thisfood = food;

}

@Override

public void beatted() {

Systemoutprintln();

}

@Override

public void outPut() {

superoutPut();

Systemoutprintln("localPlace:"+thisgetLocalPlace());

Systemoutprintln("food:"+thisgetFood());

}

}

以上就是关于Java编程作业,急用全部的内容,包括:Java编程作业,急用、Java中如何利用集合对学生管理系统的学生对象(有年龄、学号、分数等属性)按分数排名急求!!非常感谢!、siri能知道多大年龄吗等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/9509915.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-29
下一篇 2023-04-29

发表评论

登录后才能评论

评论列表(0条)

保存