Java家庭作业帮助,构造函数Mobile不能应用于给定类型;这是什么意思?

Java家庭作业帮助,构造函数Mobile不能应用于给定类型;这是什么意思?,java,Java,升级了代码,但是我现在收到了错误消息:非法的静态删除内部类Mobile.mymobile修饰符'static'只允许在常量变量删除中,第73行,public static void main(String[]args){,这意味着什么 java作业帮助 这是我的作业,这是我尝试过的作业代码。但当我试图编译它时,我不断地出现错误,我似乎也找不到解决方案: 错误表示构造函数Mobile无法应用于给定类型;必需:java.lang,int,java.lang.string;找到java.lang…。对

升级了代码,但是我现在收到了错误消息:非法的静态删除内部类Mobile.mymobile修饰符'static'只允许在常量变量删除中,第73行,public static void main(String[]args){,这意味着什么

java作业帮助

这是我的作业,这是我尝试过的作业代码。但当我试图编译它时,我不断地出现错误,我似乎也找不到解决方案:

错误表示构造函数Mobile无法应用于给定类型;必需:java.lang,int,java.lang.string;找到java.lang…。对于第44行Mobile samsungPhone=new Mobile(“三星”、“1024”、“2”、“verizon”、“8”、“GPS”)

任务简介

To write a simple java classMobile that  models a mobile phone.
Details the information stored about each mobile phone will include
•   Its type e.g.  “Sony ericsson x90” or  “Samsung Galaxy S”;
•   Its screen size in inches;
You may assume that this a whole number from the scale 3 to 5 inclusive.
•   Its memory card capacity in gigabytes
You may assume that this a whole number
•   The name of its present service provider
You may assume this is a single line of text.
•   The type of contract with service provider
You may assume this is a single line of text.
•   Its camera resolution in megapixels;
You should not assume that this a whole number;
•   The percentage of charge left on the phone e.g. a fully charged phone will have a charge of 100.
You may assume that this a whole number
•   Whether the phone has GPS or not.


Your class will have fields corresponding to these attributes .
Start by opening BlueJ, creating a new project called myMobile which has a classMobile and set up the fields that you need,
Next you will need to write a Constructor for the class. Assume that each phone is manufactured by creating an object and specifying its type, its screen size, its memory card capacity, its camera resolution and whether it has GPS or not. Therefore you will need a constructor  that allows you to pass arguments to initialise these five attributes. Other fields should be set to appropriate default values.  You may assume that a new phone comes fully charged.
When the phone is sold to its owner, you will need to set the service provider and type of contract with that provider so you will need mutator methods
•   setProvider ()  - - to set service provider.
•   setContractType - - to set the type of contract
These methods will be used when the phones provider is changed.
You should also write a mutator method ChargeUp () which simulates fully charging the phone.
To obtain information about your mobile object you should  write
•   accessor methods corresponding to four of its fields:
•   getType () – which returns the type of mobile;
•   getProvider () – which returns the present service provider;
•   getContractType () – which returns its type of contract; 
•   getCharge () – which returns its remaining charge.

An accessor method to printDetails () to print, to the terminal window, a report about the phone e.g.
This mobile phone is a sony Erricsson X90 with Service provider BigAl and type of contract PAYG. At present it has 30% of its battery charge remaining.
Check that the new method works correctly by for example,
•   creating a Mobile object and setting its fields;
•   calling printDetails () and t=checking the report corresponds to the details you have just given the mobile;
•   changing the service provider and contract type by calling setprovider () and setContractType ();
•   calling printDetails () and checking the report now prints out the new details.
Challenging excercises
•   write a mutator methodswitchedOnFor ()  =which simulates using the phone for a specified period.  You may assume the phone loses 1% of its charge for each hour that it is switched on .
•   write an accessor method checkcharge () whichg checks the phone remaing charge. If this charge has a value less than 25%, then this method returns a string containg the message Be aware that you will soon need to re-charge your phone, otherwise it returns a string your phone charge is sufficient.
•   Write a method changeProvider () which simulates changing the provider (and presumably also the type of service contract).
Finally you may add up to four additional fields, with appropriate methods, that might be required in a more detailed model.
上面是我的作业,这个作业代码我已经试过了。但是当我尝试编译它时,我不断地得到错误,我似乎也找不到解决方法:

错误表示构造函数Mobile无法应用于给定类型;必需:java.lang,int,java.lang.string;找到java.lang…。对于第44行Mobile samsungPhone=new Mobile(“三星”、“1024”、“2”、“verizon”、“8”、“GPS”)

我的代码:

         /**
 * to write a simple java class Mobile that models a mobile phone.
 * 
 * @author (Lewis Burte-Clarke) 
 * @version (14/10/13)
 */
public class Mobile

{
    // type of phone
    private String phonetype;
    // size of screen in inches
    private int screensize;
    // menory card capacity
    private int  memorycardcapacity;
    // name of present service provider
    private String serviceprovider;
    // type of contract with service provider
    private int typeofcontract;
    // camera resolution in megapixels
    private int cameraresolution;
    // the percentage of charge left on the phone
    private int checkcharge;
    // wether the phone has GPS or not
    private String GPS;
    // instance variables - replace the example below with your own
    private int x;

    // The constructor method

    public Mobile(String mobilephonetype, int mobilescreensize,
            int mobilememorycardcapacity,int mobilecameraresolution,String mobileGPS, String newserviceprovider) {
        this.phonetype =  mobilephonetype;
        this.screensize = mobilescreensize;
        this.memorycardcapacity = mobilememorycardcapacity;
        this.cameraresolution = mobilecameraresolution;
        this.GPS = mobileGPS;

        // you do not use this ones during instantiation,you can remove them if you do not need or assign them some  default values 
        //this.serviceprovider = newserviceprovider;
        //this.typeofcontract = 12;
        //this.checkcharge = checkcharge;

       Mobile samsungPhone = new Mobile(
    "Samsung" // String mobilephonetype
,   1024    // int mobilescreensize -- remove quotes
,   2      // int mobilememorycardcapacity -- remove quotes
,   8       // int mobilecameraresolution -- remove quotes, move to the right spot
,   "verizon" // String newserviceprovider -- must be the last one

);
        //typeofcontract = 12;
        //checkcharge = checkcharge;

    }

    // A method to display the state of the object to the screen
    public void displayMobileDetails() {
        System.out.println("phonetype: " + phonetype);
        System.out.println("screensize: " + screensize);
        System.out.println("memorycardcapacity: " + memorycardcapacity);
        System.out.println("cameraresolution: " + cameraresolution);
        System.out.println("GPS: " + GPS);
         System.out.println("serviceprovider: " + serviceprovider);
        System.out.println("typeofcontract: " + typeofcontract);
}


    public static void buildPhones(){
    Mobile Samsung = new Mobile("Samsung", "3.0", "4gb", "8mega pixels",
                "GPS");
        Mobile Blackberry = new Mobile("Blackberry", "3.0", "4gb",
                "8mega pixels", "GPS");
        Samsung.displayMobileDetails();
        Blackberry.displayMobileDetails();
}
    public static void main(String[] args) {
        buildPhones();
}  

}

如果您有任何答案、回复和帮助,我将不胜感激,因为我真的迷路了!

您看到的另一个问题就是这篇文章-

1024 = screensize;
2 = memorycardcapacity;
8 = resolution;
GPS = gps;
"verizon"=serviceprovider;
这是一个基本的java主题。变量。变量需要位于赋值运算符(
=
)的左侧,变量的值需要位于右侧

如果您试图修改您的
samsungPhone
对象的变量,则需要执行以下操作:

sumsungPhone.screensize = 1024;
samsungPhone.memorycardcapacity = 2;
etc...
构造函数不能应用于给定的类型;这意味着什么

这意味着您正在将错误类型的对象传递给构造函数。当声明指出某个参数是
int
时,这意味着您需要传递的是
int
,而不是包含整数的
字符串

String
常量和
int
常量之间的区别在于
String
常量使用双引号,而
int
常量不带引号

Mobile samsungPhone = new Mobile(
    "Samsung" // String mobilephonetype
,   "1024"    // int mobilescreensize -- remove quotes
,   "2"       // int mobilememorycardcapacity -- remove quotes
,   "verizon" // String newserviceprovider -- must be the last one
,   "8"       // int mobilecameraresolution -- remove quotes, move to the right spot
,   "GPS"     // String mobileGPS -- must be second before last
);

升级了代码,但我现在收到了以下错误消息:非法的静态删除内部类Mobile.mymobile修饰符“static”仅允许用于常量变量删除,第73行,公共静态void main(字符串[]args){,这是什么意思???@user2900126这意味着您不能在另一个类中声明类
mymobile
。这是否意味着我需要删除公共类mymobile{???@user2900126删除它,或者如果必须的话移动到一个单独的文件。好的,我已经从代码中删除了mymobile类,但是现在我收到了错误消息:错误表明构造函数Mobile不能应用于给定的类型;必需:java.lang,int,java.lang.string;找到了java.lang…对于第44行,Mobile samsungPhone=new Mobile(