...

View Full Version : Help but do NOT consideri it as cheating



Dev Hawk
12-17-2012, 10:54 PM
(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#.

oracleguy
12-17-2012, 11:04 PM
Ok, what is your question?

felgall
12-18-2012, 02:16 AM
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.

alykins
12-18-2012, 02:19 PM
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....


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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum