This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic