Skip to content

Instantly share code, notes, and snippets.

@heinrichquirit
Created August 6, 2014 23:52
Show Gist options
  • Save heinrichquirit/ba72b9d188802293544c to your computer and use it in GitHub Desktop.
Save heinrichquirit/ba72b9d188802293544c to your computer and use it in GitHub Desktop.
public class ClassDriver {
public static void main(String[] args) {
Superhero superman = new Superhero();
superman.setSuperPower("Strength");
superman.setComicBook("Marvel");
superman.setCanFly(true);
System.out.println("Hero's power: " + superman.getSuperPower());
System.out.println("Comic Book Series: " + superman.getComicBook());
if (superman.canFly()) {
System.out.println("And he can fly");
} else {
System.out.println("He cannot fly");
}
Movie stuartLittle = new Movie();
stuartLittle.setMovieName("Stuart Little");
stuartLittle.setMovieTime("22:00");
stuartLittle.setMoviePrice(15.50);
System.out.println("The movie is: " + stuartLittle.getMovieName());
System.out.println("The time of the movie: " + stuartLittle.getMovieTime());
System.out.println("The price of the movie: " + stuartLittle.getMoviePrice());
}
}
public class Movie {
private String movieName;
private String movieTime;
private double moviePrice;
public void setMovieName(String movieName) {
this.movieName = movieName;
}
public String getMovieName() {
return movieName;
}
public void setMovieName(String movieTime) {
this.movieTime = movieTime;
}
public String getMovieTime() {
return movieTime;
}
public void setMoviePrice(double moviePrice) {
this.moviePrice = moviePrice;
}
public double getMoviePrice() {
return moviePrice;
}
}
public class Superhero {
private String superPower;
private String comicBook;
private boolean canFly;
public void setCanFly(boolean canFly) {
this.canFly = canFly;
}
public boolean canFly() {
return canFly;
}
public void setComicBook(String comicBook) {
this.comicBook = comicBook;
}
public String getComicBook() {
return comicBook;
}
public void setSuperPower(String superPower) {
this.superPower = superPower;
}
public String getSuperPower() {
return superPower;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment