How to set / get in Java?

Question by Clayton: How to set / get in Java?
I don’t know if it’s just me or these instructions, but I have been digging around my textbook and online. I can’t seem to find a concrete way to do this problem:

Problem A: Antique Toy Inventory . Objectives: Creating classes, passing parameters to objects from a driver, retrieving data from an object.
Write a class named AntiqueToys which represents an object that tracks a particular toy in your collection of antique toys. It has the following attributes: description, maker, year made, value.
Write appropriate mutator (set) methods which update the attribute values, and accessor (get) methods which return the attribute values. Create a driver program which creates three toy objects, stores the following values in each, and then displays the values for each toy. Read at least one toy’s data from the keyboard. Data for the other two may be ‘hard-coded’ as literals in your driver.
Description Maker Year Made Value
Electric Train Lionel 1934 $ 459.95
Handcar Coin Bank J&E Stevens 1883 $ 2,195.00
Stuffed Bear Steiff 1905 $ 214.00

Any help is greatly appreciated.

Best answer:

Answer by Advanced Knowledge
Here is a small version of the Antique Toys Class, hope it helps:
public class AntiqueToys{
private String description, maker;
private int year_made;
private double value;
//empty default constructor
public AntiqueToys(){
//Example of Mutator
void setDescription(String desc)
//Example of accessor
String getDescription()
return description;

What do you think? Answer below!

Comments are closed.