How to do abstraction

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

32 Replies - 1053 Views - Last Post: 16 November 2018 - 02:17 PM Rate Topic: -----

#31 andrewsw   User is offline

  • head thrashing
  • member icon

Reputation: 6646
  • View blog
  • Posts: 27,203
  • Joined: 12-December 12

Re: How to do abstraction

Posted 16 November 2018 - 02:25 AM

So are you still asking about the very large number that you entered? I responded to that question.

Or do you have another question?
Was This Post Helpful? 0
  • +
  • -

#32 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2691
  • View blog
  • Posts: 10,774
  • Joined: 03-December 12

Re: How to do abstraction

Posted 16 November 2018 - 08:05 AM

So, @StudentCoder, how is the work going? Are you understanding what and why you are doing things yet, or are you still trying to stumble through it?
Was This Post Helpful? 0
  • +
  • -

#33 TechnoBear   User is online

  • Lady A
  • member icon

Reputation: 279
  • View blog
  • Posts: 1,095
  • Joined: 02-November 11

Re: How to do abstraction

Posted 16 November 2018 - 02:17 PM

I'd put the validation for year where you're setting the year, instead of an extra method.
Every vehicle has a type, so I'd have a variable for Type in Vehicle, adjust Vehicle constructor to accept year and type and then supply those values from the sub classes where their constructor will accept year and supply type. Then getType() doesn't need to be abstracted.

I also wouldn't have exception catching in the classes themselves but handled where you're creating them.

Abstraction in and of itself is incredibly simple when you understand it.

In it's simplest of simple terms:
Parent //Blonde Hair
  |
  V
Child //Blonde Hair (from Parent), Blue Eyes
  |
  V
Child's Child //Blonde Hair (from Parent), Blue Eyes (from Child), Fair Skin

Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3