Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

C++, Throwing and Catching

Name: Anonymous 2005-03-04 15:26

PROGRAM 6                EXCEPTION HANDLING            
        
------------------------------------------------------------------------- 

 1. Define an Employee class.
    a) has data members EmpNum and Pay.
    b) EmpNum has format XXX-Y where each X is a digit in {0-9} and
       Y is a letter in {A-M}.
    c) Pay is in {1000-7000}.
    d) member function SetEmpNum to validate and assign value to EmpNum.
    e) member function SetPay to validate and assign value to Pay.
    f) constructor to accept values for EmpNum and Pay.
    g) exception InvalidEmpNum to be thrown from constructor when an
       invalid value for EmpNum is received.
    h) exception InvalidPay to be thrown from constructor when an
       invalid value for Pay is received.
  
 2. Write a test program to demonstrate the exceptions.
 
 
 -------------------------------------------------------------------------

Submit Source Code listing your solution and results

Discuss

Name: Anonymous 2005-03-04 15:34 (sage)

Your teacher is a bore.

Name: Anonymous 2005-03-04 17:09 (sage)

EmpNum should clearly be an abstract data type of its own, and not some freak-string-hybrid.

Name: Anonymous 2005-03-05 10:59 (sage)

>>3 me too me too!

If an error is found, the exception should be thrown by the invalid object. So you'll have to split EmpNum outside (thanks to the OO properties of C++)

Name: !b3iEdnvlLM 2007-10-25 10:09

just sagetriptesting, nvm me

Name: !1FSSBwu5y6 2007-10-25 10:09

just sagetriptesting, nvm me

Name: !.qzJRn9QqU 2007-10-25 10:10

just sagetriptesting, nvm me

Name: !AEZXYDj79k 2007-10-25 10:10

just sagetriptesting, nvm me

Name: !bfE4ciC6Vw 2007-10-25 10:10

just sagetriptesting, nvm me

Name: !vHBaM7fWkQ 2007-10-25 10:11

just sagetriptesting, nvm me

Name: !CY2rKBCd6E 2007-10-25 10:11

just sagetriptesting, nvm me

Name: !xaqcvztJ6s 2007-10-25 10:12

just sagetriptesting, nvm me

Name: Anonymous 2009-01-15 7:27

use c faggit

Name: !!Yf8pcFSt9+0YlHk 2009-01-15 18:37

trip testan games? let me join the fun!

Name: Anonymous 2009-03-06 8:09


The bleeding edge extremely.

Name: Anonymous 2010-12-06 10:00

Back to /b/, ``GNAA Faggot''

Name: Anonymous 2013-05-23 2:44

[url]http://bull.shit[/url]

Name: Anonymous 2013-07-23 8:33

check em

Name: Anonymous 2013-07-23 9:47

We can define an f-coalgebra to describe your program. But to incorporate exceptions, we need to adjust the state space, which is undesirable, because it complicates the space. We can however choose to adjust the codomain, creating an coalgebra:

S -> S x E

This has some drawbacks, but keeps our state space nice and simple.

In C++ we have the concept of a loop or a computation that doesn't terminate. To fully describe your system we need the following adjustment:

S -> Sb x E, where Sb = bottom U S

With this structure, we can describe your specification on a more rationale basis. So is E = {InvalidEmpNum, InValidPay} and S is a copointed functor with arrows Pay : S -> N and Empnum : S -> N x Char and a natural transformation S -> Sb.

Following this line, you could create a suitable model of computation, which you can transfer back to C++. I hope it helps.

Name: Anonymous 2013-07-23 10:30

>>20

You meana haskell?

And S -> Sb + (Sb x E), an Exception is not always thrown.

Name: Anonymous 2013-07-23 13:06

>>20
What kind of faggotry is this? Something to do with category theory but I am not sure how that applies to algorithms.

Name: Anonymous 2013-07-23 15:58

>>22

Seems that he tries to use coalgebras to structure the computation, but he fails to some extent. He claims that C++ throws an exception at every computation step.

A f(unctor)-coalgebra is a mathematical structure with a endofunctor F : C -> C (this is a map between Categories, (which are maps between objects). In this case C contains the state space, the variables of your program.
And a morphism t : a -> F b (which represent the stateful computations). If you want to fit an algorithm, it should have this form.

Only algorithms that use state are nicely modelled with coalgebras, others are rather cumbersome.

Name: Anonymous 2013-07-23 16:15

>>21
Can't Haskell be modeled with a less gay math known as Abstract Algebra?

Name: Anonymous 2013-07-23 16:25

>>24

That is a rather broad subject. Category theory falls under Abstract Algebra and yes a lot of shit is modelled with category theory.

Name: Anonymous 2013-07-23 16:38

The thing is: it doesn't matter, it's all Jewish crap made to oppress the goyim.

Name: Anonymous 2013-07-23 16:46

Name: Anonymous 2013-07-23 17:07

>>26

This was not about jews. At least use sage, when you deliver your jew spam.

Name: Anonymous 2013-07-23 19:03

>>28
Nikita never uses sage, silly kike/mudslime.

Name: Anonymous 2013-07-25 13:12

>>29

What the fuck are you? His personal biographer/cum dump?

Name: Anonymous 2013-07-25 15:30

>>29
Tiresome nonsense

Name: Anonymous 2013-07-25 16:41

>>29

Because he is an idiot, who cannot find work. If you need to sage a post, put sage in the email field.

Name: Anonymous 2013-07-25 16:58

>>30
No, just someone who notices patterns easily. I've never seen him using sage.

Name: Anonymous 2013-07-25 17:04

>>32
Well I suppose either Walmart or Safeway would hire him if he told them that he was mentally retarded. This is because both of these firms hire retards all the time. Presumably because that is the one group that the management can look "smart" in front of or what nit.

Name: Anonymous 2013-07-25 17:06

>>34
By the way, I know this from personal experience because wasted three years of my life working as an associate at Walmart. And like, uh, right now, I work for Safeway.

Name: Anonymous 2013-07-28 14:45

What happened OP? You got your homework done in time?

Name: Anonymous 2013-07-29 0:56

>>36
Not yet, but he got an extension so it's fine.

Name: Anonymous 2013-07-29 15:01

>>37


The reason that people are hardly helping, is that it is extremely simple and thus boring.


recipe:

Make three stub classes (Employee, InvalidPay, InvalidEmpNum)
The last two should derive from exception.
Add your members to your employee class, make the protected: empNum and pay
Add your functions to your employee class, make them public: SetEmpNum, SetPay. Check the input they receive. Throw the appropiate exception if the input is not correct. Else modify the member field.

Done with this shit. Now show the 4 cases, which can happen:
    Input of
Payment   EmpNum
correct   correct
incorrect correct
correct   incorrect
incorrect incorrect

Describe what happens for each one. Done. Why does he need an extension for this?

Don't change these.
Name: Email:
Entire Thread Thread List