Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help but do NOT consideri it as cheating

    (The Fan class)
    Design a class named Fan to represent a fan. The class contains:

    Three static public constants named Slow, Medium and Fast with values 1, 2 and 3 to denote the fan speed. "Note that "public int constant" is error".

    A private int data field named that specifies the speed of the fan (default Slow).
    A private bool data field on that specifies whether the fan is on (default false).
    A private double radius (default 5).
    A private string color blue (default blue).
    A properties for all 4 data fields.

    No-arg constructor that creates a default fan. Use this ref. // I think it is like Public class Fan:this(Slow, false, 5, "Blue").

    1-are constructor that creates a fan. Provide speed value.
    2-arg constructor that creates a fan. Provide speed and on values.
    3-arg constructor that creates a fan, Provide speed, on and radius values.
    4-arg constructor that creates a fan. Provide speed, on, radius and color values.

    A method named DisplayFan() 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 not on, the method returns fan color and radius along with the string "fan is off' in one combined string.


    Write a test program that creates 2 Fan objects. Assign maximum speed, radius 10, color yellow and turn it on the first object. Assign medium speed, radius 5, color blue and turn it off to the second object. Display the objects by invoking their DisplayFan method.


    Using C#.

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Ok, what is your question?
    OracleGuy

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    If your code isn't working then we'd need to see what code you have in order to be able to provide any help. You should at least have made an effort to create all of the properties and methods asked for prior to asking for help.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,805
    Thanks
    41
    Thanked 199 Times in 198 Posts
    Quote Originally Posted by Dev Hawk View Post

    No-arg constructor that creates a default fan. Use this ref. // I think it is like Public class Fan:this(Slow, false, 5, "Blue").
    This is the only part I see you did any work- without giving too much away....
    Code:
        class Program
        {
            static void Main(string[] args)
            {
                fan f = new fan();
            }
        }
    
    
        public class fan
        {
            private string PretendValue;
            private int PretendValue2;
    
            public fan()
            {
                PretendValue = "cat";
                PretendValue2 = 5;
                this.display();
            }
    
            private void display()
            {
                Console.WriteLine("{0}, {1}\nfin...", PretendValue, PretendValue2);
                Console.ReadLine();
            }
        }
    I do believe that will give you a lot to work with

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •