设计一个名为Fan的类来代表粉丝。该类包含: [英] Design a class named Fan to represent a fan. the class contains:

查看:463
本文介绍了设计一个名为Fan的类来代表粉丝。该类包含:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好程序员^^

i''我刚来这里......所以..

i从我的演讲中获得了作业。



•三个静态常量,名为SLOW,MEDIUM和FAST,值为1,2和3,表示风扇速度。

•一个名为speed的私有int数据字段指定风扇的速度,默认为慢。

•名为on的私有布尔数据字段,指定风扇是否打开,默认为false。

•名为radius的私有双数据字段,指定风扇的半径,默认为5.

•名为color的私有字符串数据字段,指定风扇的颜色,默认为蓝色。

•所有4个数据字段的属性。

•无参数构造函数,用于创建默认粉丝。使用此参考号。

•创建扇形的单参数构造函数。提供速度值。

•一个创建扇形的双参数构造函数。提供速度和价值。

•一个创建风扇的三参数构造函数。提供速度,开启和半径值

•一个创建扇形的四参数构造函数。提供速度,开启,半径和颜色值。



•DisplayFan()方法,返回风扇的字符串描述。如果风扇打开,则该方法会在一个组合字符串中返回风扇速度,颜色和半径。如果风扇关闭,该方法返回风扇颜色和半径以及字符串,风扇关闭在一个组合字符串中。



风扇应用程序类



•编写一个创建两个Fan对象的测试程序。

•风扇对象1输入:

o分配最快速度。

o指定半径10

o指定颜色为黄色

o打开风扇。

•风扇对象2输入:

o分配中速。

o指定半径5

o指定蓝色

o关闭风扇。

Hello programmers ^^
i ''am new here... so..
i got assignment from my lecture.

• Three static constants named SLOW, MEDIUM, and FAST with the values 1, 2, and 3 to denote the fan speeds.
• A private int data filed named "speed" that specifies the speed of the fan, default to slow.
• A private Boolean data field named "on" that specifies whether the fan is on, default to false.
• A private double data field named "radius" that specifies the radius of the fan, default to 5.
• A private string data field named "color" that specifies the color of the fan, default to "blue".
• A properties for all 4 data fields.
• A no-argument constructor that creates a default fan.use this ref.
• A one-argument constructor that creates fan. provide speed value.
• A two-argument constructor that creates fan. provide speed and on value.
• A three-argument constructor that creates fan. provide speed , on , and radius value
• A four-argument constructor that creates fan. provide speed , on , radius , and color value.

• A DisplayFan( ) method that returns a string description for the fan. If the fan is on, the method returns the fan speed, color, and radius in one combined string. If the fan is off, the method returns the fan color and radius along with the string, "fan is off" in one combined string.

The Fan Application class

• Write a test program that creates two Fan objects.
• Fan Object 1 inputs:
o Assign Fastest Speed.
o Assign a radius 10
o Assign the color yellow
o Turn the fan on.
• Fan Object 2 inputs:
o Assign Medium Speed.
o Assign a radius 5
o Assign the color blue
o Turn the fan off.

推荐答案

是的,得到了一项任务,所以你应该做这项工作。
Yes, you got an assignment so you are expected to do the work.


正如你所说这是你的任务,所以最好是你自己做的。

这是给你的,这样你就可以学到一些东西,想想所教的内容。阅读你的教科书并尝试一下。



一旦你有代码并遇到问题,你可以随时回到这里,提出更具体的问题,社区将做最好的帮助你。不要忘记仅发布造成问题的相关代码位,因为代码转储通常对帮助/协助您没有帮助。



祝你好运,编码愉快。
As you said this is your assignment, so it would be best if you did it your self.
It is given to you so that you will learn something, think about what have been taught. Read your text books and give it a try.

Once you have code and run into problems you can always come back here with a more specific question and the community will do its best to help you. Don''t forget to post only the relevant code bits that pose the problem as a code dump is not usually helpful at all in getting someone to help/assist you.

Good luck and happy coding.


你应该编译并运行你的代码,看它是否符合要求。当你编译它时,你会得到错误(如果出现问题),这将导致你朝着正确的方向前进。作为初学者,你需要练习,修复错误并获得经验。
you should compile and run your code and see if it works as the requirements dictate. When you compile it you will get errors (if something went wrong) that will direct you in the right direction. as a beginner you need to practice, get errors fix them and gain experience.


这篇关于设计一个名为Fan的类来代表粉丝。该类包含:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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