Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

Class With Getter and Setter Methods

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was trying to design a class with getter and setter methods recently, (keep in mind im very new to java)where a class (a vehicle) has two variables. A String (Licence Plate) and an Integer (Wheels). Both classes had getter and setter methods.

I wrote the following code for the class:

Class VehicleClass

public variable LicencePlate string;
public variable Wheels Integer;

function VehicleClass (name: string; string){
this.LicencePlate
}
function get LicencePlate () string;{
Return this.LicencePlate
}
function set LicencePlate(name:string){
this.LicencePlate = name

function VehicleClass (name: integer; integer){
this.Wheels
}
function get Wheels () integer;{
Return this.Wheels
}
function set Wheels(number:integer){
this.Wheels = number


How far off am i being right?
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simon,

May I suggest you read up a bit more on Java as it doesn't look like you even understand the basics yet. x()

Either that, or you've posted this topic in the wrong forum as the code you posted isn't Java..

Regards,
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I'm recalling correctly, that looks a bit like VB. Do I get a cookie?
 
Does this tiny ad smell okay to you?
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic