• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

syntax again

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry if im spamming, im just trying to get the hang of things now whats wrong with this?


Much thanks,
Jacob
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dvdplayer doesn't have a method named playDVD(), but you're calling one?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, first you're naming the class 'dvdplayer' and later you're referring to it as 'DVDPlayer'. Note that Java is case-sensitive, so 'dvdplayer' is not the same as 'DVDPlayer'.
 
Jacob Rich
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
they're two different classes though, i thought different classes dont apply to one another unless it inherits?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you are saying you have two different classes, one called "dvdplayer" and the other called "DVDPlayer", and they both have a "recordDVD" method and a boolean property named "canRecord"? That's going to get really confusing in a hurry. I advise you don't do that.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by jacob rich:
they're two different classes though...


 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by jacob rich:
they're two different classes though[...]


Looks to me like a violation of the DRY principle (Don`t Repeat Yourself).

Originally posted by jacob rich:
, i thought different classes dont apply to one another unless it inherits?



Huh?! Please re-phrase.
 
Jacob Rich
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, one class is DVDPlayer and one is DVDTestDrive..
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


get it?
 
Jacob Rich
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
right, so i could have said dvd1 = new DVDsystem? or ... ?
 
Adam Schaible
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, let me try again.

A class can be viewed as a template for an object, it defines behaviors and attributes. If I want to create a new instance of a class (an object), I must identify this object by the identical name found in the class, so - for example

Must be identified by:


See how the class file is named identically to the object instance?

So in your example:


To create an instance of the dvdplayer, you'd have to modify your code:



Now, you're also missing a playDVD() method in dvdplayer - that will need to be added to the dvdplayer class.
 
Jacob Rich
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ah, that cleared things up alot, thanks
 
Legend has it that if you rub the right tiny ad, a genie comes out.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic