Skip to content

Instantly share code, notes, and snippets.

@mattymess
Created November 14, 2018 19:05
Show Gist options
  • Save mattymess/74984e4e5cabc7afb303c33a4b59ab5a to your computer and use it in GitHub Desktop.
Save mattymess/74984e4e5cabc7afb303c33a4b59ab5a to your computer and use it in GitHub Desktop.
Dog
class Kennel {
public static void main(String[] args) {
int numOfDogs = 3;
String kennelName = "The Kennel";
double costPerNight = 10.00;
// <type of class> <variableName> = <variableValue>
Dog someDog = new Dog("Riley");
Dog dog2 = new Dog("Cali");
System.out.println(someDog.name);
System.out.println(dog2.name);
// write a loop that loops over numOfDogs and prints the name of each dog
// expected output:
// Riley
// Cali
// Riley
// Cali
// Riley
// Cali
}
}
class Dog {
public String name;
public Dog(String dogName) {
this.name = dogName;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment