我该如何设置这个程序?有更简单的方法吗? [英] How do I setup this program? Is there an easier method?

查看:64
本文介绍了我该如何设置这个程序?有更简单的方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建一个参数温度的超类降水量。它应该有方法toString()*返回温度。应该有一个子类rain也有参数amount,getAmount()和toString()*返回温度和数量*作为方法和子类,也有snowDepth作为参数和getDepth()和toString()*返回温度和深度*作为方法。



我尝试过:



尝试使用main方法构造函数进行设置,并使用不同的参数。无法找出int到字符串错误。

Create a superclass precipitation that takes in the parameter temperature. It should have the method toString()*returns the temperature. There should be a subclass rain that also has a parameter amount and getAmount() and toString()*returns the temperature and the amount* as methods and a subclass that also has snowDepth as a parameter and getDepth() and toString()* returns the temperature and the depth* as methods.

What I have tried:

Tried to setup using main method constructor, and with the different parameters. Couldn't figure out the int to string error.

推荐答案

Quote:

我该如何设置这个程序?有更简单的方法吗?

How do I setup this program? Is there an easier method?



你知道我们不知道你做了什么吗?

我们无法读懂你的想法或你的屏幕。

如果您需要有关代码的帮助,则需要显示并询问具体问题。



我们不做你的HomeWork 。

HomeWork不会在乞求别人做你的工作时测试你的技能,它会让你思考并帮助你的老师检查你对你所学课程的理解。你应用它们时遇到的问题。

你的任何失败都会帮助你的老师发现你的弱点并设定补救措施。

你的任何失败都会帮助你了解什么有效,什么无效,被称为'试错'学习。

所以,试一试,重读课程并开始工作。如果您遇到特定问题,请显示您的代码并解释这个问题,我们可能会提供帮助。


Do you know that we have no idea what you have done?
We can't read your mind or your screen.
If you want help on your code, you need to show it and and ask a specific question.

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.


public class Precipitation
{
    public int temperature;
    
    public Precipitation(int temperature)
    {
        this.temperature = temperature;
    }
    
    public String toString()
    {
        return temperature;
    }

This is what I have. I'm unable to figure out how to convert the int to the string , as seen in the toString. I know that we have to use the int to String convertor. The actual question is where to place it?


这篇关于我该如何设置这个程序?有更简单的方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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