473,394 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Where to start

Don't know where to start

Problem:

Create a class Rectangle The class has attributes length and width, each of
which defaults to 1. It has member functions that calculate the perimeter
and the area of the rectangle. It has set and get function for both length
and width. The set functions should verify that length and width are each
floating point numbers larger than 0.0 and less than 20.0
Jul 22 '05 #1
5 2242
David wrote:
Don't know where to start

.... an empty class will do fine....... ain't that straightforward ?!
empty class => add two attributes => add two methods => done.
Jul 22 '05 #2
In article <UQenc.419691$oR5.121352@pd7tw3no>, David wrote:
Don't know where to start

Problem:

Create a class Rectangle The class has attributes length and width, each of
which defaults to 1. It has member functions that calculate the perimeter
and the area of the rectangle. It has set and get function for both length
and width. The set functions should verify that length and width are each
floating point numbers larger than 0.0 and less than 20.0

[-]
class Rectangle {
/*
** The rest of your homework here
*/
};
Jul 22 '05 #3
David writes:
Don't know where to start

Create a class Rectangle The class has attributes length and width, each of which defaults to 1. It has member functions that calculate the perimeter
and the area of the rectangle. It has set and get function for both length
and width. The set functions should verify that length and width are each
floating point numbers larger than 0.0 and less than 20.0


Gee you missed a lot didn't you? Try this:

class Rectangle
{
public:
// prototypes of member functions go here
private:
// data go here
};
// functions go here. I think there are seven of them.

int main()
{
Rectangle rect(3.0, 4.0); /* rect is an *object* as
specified by the *class* Rectangle.
Rectangle is a type, rect is a variable */
// experiment with several permutations of the various functions
including the constructor.
}

I would think that, for consistency, the constructor would check for values
within the specified range *too*.
Jul 22 '05 #4
Ian
David wrote:
Don't know where to start
Not here!

Problem:

Create a class Rectangle The class has attributes length and width, each of
which defaults to 1. It has member functions that calculate the perimeter
and the area of the rectangle. It has set and get function for both length
and width. The set functions should verify that length and width are each
floating point numbers larger than 0.0 and less than 20.0

This looks like a homework problem, read you notes or text book and post
an attempt, you will get more help that way.

Ian
Jul 22 '05 #5

"David" <d_***@shaw.ca> wrote in message
news:UQenc.419691$oR5.121352@pd7tw3no...
Don't know where to start

Problem:

Create a class Rectangle The class has attributes length and width, each of which defaults to 1. It has member functions that calculate the perimeter
and the area of the rectangle. It has set and get function for both length
and width. The set functions should verify that length and width are each
floating point numbers larger than 0.0 and less than 20.0


Have you actually attended any classes or read any books? Honestly it's
really hard to imagine a C++ assignment that is much simpler.

Here's the deal, have a go yourself. Sounds like you will get some things
wrong, maybe you will get everything wrong. But that doesn't matter. When
you have had a go and get stuck come back here and post the code you have
written, then you will get help with it.

Alternatively at least say what you are stuck on, then at least we'd have a
question to answer, rather than just a request to do your homework for you.

john
Jul 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Nat | last post by:
Hi there, I have code as following but it returns error Error Type: Microsoft VBScript compilation (0x800A03F6) Expected 'End' /urbisjhdintranet/metadata/resultList.asp, line 324 which is the...
2
by: MT McNasty | last post by:
Hi. I'm trying to start modifying a VNC client (say RealVNC or UltraVNC). My problem is that I don't even know where to begin? I can't find a list of API's on any of them, and I just don't know...
2
by: GAVO. | last post by:
This probably is not the best group to post this question but any ways. I've been working with ms access for the last couple of years and gotten very good at it. I have never been on any ms...
7
by: Mr. Mountain | last post by:
In the following code I simulate work being done on different threads by sleeping a couple methods for about 40 ms. However, some of these methods that should finish in about 40 -80 ms take as long...
14
by: Odinn | last post by:
Greetings , This is my first year at programming and 3rd week at this so count me as a pure newbie. I am trying to make a program that gets a number and prints out starts as this: For input 3 :...
3
by: saundra | last post by:
This appears to be the code that is giving me trouble. Can someone help <? include("common.php"); require_once("$HeaderFile"); if(empty($_GET)){ $Start = '0'; }else{ $Start = $_GET;
5
by: =?Utf-8?B?cm9jY28=?= | last post by:
Hello, easy question: - what are the best books to start learning C#? Thanks! Rocco
2
by: Ceebaby via AccessMonster.com | last post by:
Hi Folks I wondered if someone could point me in the right direction before I completely tear my hair out. I have a user selection form where options can be selected for a report. Users now...
37
by: Phlip | last post by:
1230987za wrote: Kanze is a classically-trained "unit tester". In some circles "unit" is a QA concept - specifically, if a test fails, you only need to inspect one unit. So "units" are...
2
natalie99
by: natalie99 | last post by:
Hi All I thought this would be easy but I am having great difficulty! Could someone kindly please explain where I am going wrong? I have a single table of data, tblA each line shows a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.