Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Basic program help

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Basic program help

    Hello, I've recently started a Computer Science course but due to illness I've missed the majority of the lectures in the first 3 weeks. I have been set a basic task where I have to create a Class that will model a mobile phone.
    It will have fields that correspond to the type of phone, memory, service provider, contract type, camera res, phone battery.

    It Will have a constructor for the class to pass arguments between the attributes with other fields set to default values.

    Once the phone is sold it will need mutator methods to set the type of contract and the service provider. These will be setProvider() and setContractType()

    A mutator method chargeUp() shouldalso simulate fully charging the phone. Accessor methods are needed to to retrieve information from fields. getType, getProvider etc.


    This is a brief overview of the task and I'm not sure where to go and further than creating the class and variables. I'd appreicate if someone could advise on where to go from there with a brief explanation so I can continue.

    Thanks in advance.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,718
    My Mood
    Mellow
    Thanks
    231
    Thanked 706 Times in 692 Posts

    Default Re: Basic program help

    Start by going through the assignment a line at a time and doing exactly what it says. For example:
    // create a Class that will model a mobile phone
    public class MobilePhone
    {
     
    }
    You fill in the rest. Come back when you need help.

  3. #3
    Junior Member
    Join Date
    Oct 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Basic program help

    public class Mobile
    {
        //Declaring the variables of the Class.
     
        private int ScreenSize;
        private String PhoneType; 
        private int Memory;
        private String ServProv;
        private String Contract;
        private float CamRes;
        private int Battery;
        private boolean Gps;

    This is what I put in, but the String doesnt come up in red like the other data types and I'm not sure why. I'm given this by the IDE (BlueJ) to do next.

    /**
         * Constructor for objects of class Mobile
         */
        public Mobile()
        {
            // initialise instance variables
     
        }

    Not completely sure what to do next.

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,718
    My Mood
    Mellow
    Thanks
    231
    Thanked 706 Times in 692 Posts

    Default Re: Basic program help

    Keep going through the assignment line by line and doing what it says. I'm not sure why you're distracted by what BlueJ says to do (not even sure what that means), but keep working on the assignment. BlueJ is not being graded for your work, you are.

  5. #5
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 168 Times in 159 Posts

    Default Re: Basic program help

    Most IDE's do not use syntax highlighting for classes.
    Improving the world one idiot at a time!

Similar Threads

  1. Basic Java Program Help
    By csbtia in forum Java Theory & Questions
    Replies: 1
    Last Post: July 3rd, 2012, 11:25 AM
  2. need help with this basic program containing loops
    By kingslayer in forum Loops & Control Statements
    Replies: 2
    Last Post: March 23rd, 2012, 06:54 PM
  3. Re: Basic Java Program Help
    By Tanushri in forum Java Theory & Questions
    Replies: 3
    Last Post: January 17th, 2012, 11:43 PM
  4. BASIC program help
    By ryanquanz in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 15th, 2011, 09:42 AM
  5. Basic Java Program Help
    By roaster in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 6th, 2009, 10:28 PM