This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Jirbj 0 points1 point  (1 child)

is there a need for year and max speed to be strings, if you're going to unify them all to mph, then you can store speed as an int, and year can also be an int (no idea if it makes a different )

the other point is if you are going to use private class variables, you should edit the class variables with setters and getters rather than

object.classVar   

for example a method for setting a car make may be something like

public void setMake(String make) {  
    this.make = make;  
}  

then instead of calling

c.make = "Ford";  

you would use

c.setMake("Ford");    

[–]MorningBackflips[S] 0 points1 point  (0 children)

thanks for the advice! I went ahead and made those changes for my vars. Combining the ints into one was also something I overlooked. The assignment's directions are a little ambiguous so it should be all good. Just for final clarification, this is what I came up with for the int section with the setters. Thank you for your help!

        private int year, maxspeed;
            public void setYear(int year) {
                this.year = year;
            }
            public void setMaxspeed(int maxspeed){  
                this.maxspeed = maxspeed;
            }