Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- public class DogOwner{
- private String ownerName;
- private int foodAmount;
- private Dog dogOne = new Dog();
- private Dog dogTwo = new Dog();
- public DogOwner(){
- Random randNum = new Random();
- ownerName = "some name";
- foodAmount = randNum.nextInt(40) + 10;
- dogOne.setName("Fido");
- dogTwo.setName("Fido");
- }
- public String getOwnerName(){
- return ownerName;
- }
- public void setOwnerName(String newOwnerName){
- ownerName = newOwnerName;
- }
- public int getFoodAmount(){
- return foodAmount;
- }
- public void setFoodAmount(int newFoodAmount){
- foodAmount = newFoodAmount;
- }
- public int feedDog(){
- foodAmount = (foodAmount - 1);
- System.out.println("Remaining food = " + foodAmount);
- return foodAmount;
- }
- public static void main(String args[]){
- DogOwner test = new DogOwner();
- test.setFoodAmount(25);
- System.out.println("Initial food = " + test.getFoodAmount() );
- test.feedDog();
- Dog noError = new Dog();
- noError.setSpeed(5);
- dogOne.setSpeed(5);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement