有人可以帮我这个(java) [英] Can someone please help me with this (java)

查看:66
本文介绍了有人可以帮我这个(java)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您正在设计大学的公共汽车系统。每辆巴士有不同的出发时间。公共汽车总是在小时开始时离开(例如:10点尖锐,13点尖锐,16点尖锐)。



写下class bus包含公交车的名称,所有出发时间,以一组小时数表示(一天24小时)以及以下所有方法:



1.方法runTogether检查实际总线是否每天至少与另一个总线(作为参数接收)同时运行(提示:使用Set的方法)。



2.静态方法allTimes接收两个总线并显示所有出发时间而不重复(提示:使用Set的方法)。



3.Getters和setter。



4.Method toString返回公交车的信息。



5.绘制UML图对于这个问题。



6.编写一个程序来测试你的类,你应该创建两个总线对象并测试你的所有方法是否正常工作。注意:所有输入都应该从用户那里读取。



我尝试过:



这就是我的开始,但现在我不知道下一步该做什么。







公共级巴士{



字符串busname;

int dphours;



public void setRunTogether(int dphours){



if()



}





}

You are designing a university’s bus system. Each bus has different departure times. The buses always depart at the start of the hour (example: 10 o’clock sharp, 13 o’clock sharp, 16 o’clock sharp).

Write the class Bus that contains the bus’ name, all its departure times, represented as a set of hours (there are 24 hours in a day) and all the following methods:

1.The method runTogether that checks whether the actual bus runs at the same time with another bus (received as a parameter) at least once a day (Hint: use Set’s methods).

2.The static method allTimes that receives two buses and displays all their departure times without duplication (Hint: use Set’s methods).

3.Getters and setters.

4.Method toString returns the bus’s information.

5.Draw a UML diagram for this problem.

6.Write a program to test your classes, you should create two bus objects and test that all your methods work properly. Note: all inputs should be read from the user.

What I have tried:

This is what I've started with, But now I don't know what to do next.



public class bus {

string busname;
int dphours;

public void setRunTogether (int dphours){

if ()

}


}

推荐答案

引用:

您正在设计大学的公共汽车系统。

You are designing a university’s bus system.

这意味着不是互联网上的陌生人。家庭作业问题的目的是测试你的知识和学习,而不是测试你让别人去做你的工作的能力。仔细阅读问题,记下完成每个阶段所需的步骤,并分别编码和测试每个阶段。

That means you not some stranger on the internet. Homework questions are set to test your knowledge and learning, not to test your ability to get someone else to do your work. Read the question carefully, make notes about what steps are needed to complete each stage, and code and test each stage separately.


这篇关于有人可以帮我这个(java)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆