Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package car;
- /**
- *
- * @author 01603679
- */
- public class Car {
- static int carsCreated;
- String model;
- int year = 21;
- public Car()
- {
- }
- public Car(String Model, int Year)
- {
- model = Model;
- year = Year;
- carsCreated++;
- }
- public Car(Car copycar)
- { copycar.setModel(model);
- copycar.setYear(year);}
- //Constructors
- public void setYear(int Year){year = Year;}
- public void setModel(String Model){model = Model;}
- //Retrivers
- public int getYear(){return year;}
- public String getModel(){return model;}
- public String toString()
- {
- String ret ="dsfa";
- return ret;
- }
- public boolean equals(Car car1, Car car2)
- {Boolean ans = true;
- return (model.equals(car2.getModel()) && year==(car2.getYear()));}
- public static void main(String[] args) {
- Car c1 = new Car();
- c1.setYear(2011);
- c1.setModel("Outback");
- Car c2 = new Car("Prisim", 1998);
- Car copy1 = new Car(c1);
- System.out.println(c1.getModel());
- System.out.println(c1.getYear());
- System.out.println(c2.getModel());
- System.out.println(copy1.getModel());
- // TODO code application logic here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement