Hi, i have a hw assignment and i need help. I have done the first class already which is the city class. Heres what i got:

public class cityclass{

 
    private String cityname;
    private int days;
    private double cost;
    private float rating;

    
    public cityclass(String newcityname, int newdays, double newcost, float newrating)
    {
        this.cityname = newcityname;
        this.days = newdays;
        this.cost = newcost;
        this.rating = newrating;
    }

    
    public void setcityname(String newcityname)
    {
        this.cityname = newcityname;
    }

    
    public void setdays(int newdays)
    {
        this.days = newdays;
    }
    
    
    public void setcost(double newcost)
    {
        this.cost = newcost;
    }
  
    public void setrating(int newrating)
    {
        this.rating = newrating;
    }

    

    
    public String getcityname()
    {
        return this.cityname;
    }

    
    public int getdays()
    {
        return this.days;
    }

    
    public double getcost()
    {
        return this.cost;
    }

    
    public float getrating()
    {
        return this.rating;
    }

    

    
    public String howGood()
    {
        return null;
    }

    
    public void print()
    {
        System.out.print("CityName: " + this.cityname + " Days" + this.days + "cost" + this.cost + "Rating"+ this.rating);
       
        }
    }

Edited 6 Years Ago by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

nice assignment but in this forum you have to do it your self
you did the city class it means you can do the rest but you are lazy
if you want to have a good computer science career you have to be creative
what you are asking for here is the entire solution but i think you should try and ask for what you dont know

oh, im not asking to do it for me. Im asking if the code for the first class is correct or if im missing something. Im working on the other class, which i will also post to see if its correct.

it is perfectly fine.. only thing is naming convention is not correct.
setname should be changed to setName, setcost should be changed to setCost ..............
otherwise everything else is fine

This article has been dead for over six months. Start a new discussion instead.