Skip to content

almost #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/main/java/io/zipcoder/polymorphism/Bird.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.zipcoder.polymorphism;

public class Bird extends Pet {
String name;

@Override
public String getName() {
return name;
}

@Override
public void setName(String name) {
this.name = name;
}

public Bird(){
super("Tweety");
}

@Override
public String speak() {
return "Chirp";
}
}
23 changes: 23 additions & 0 deletions src/main/java/io/zipcoder/polymorphism/Cat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.zipcoder.polymorphism;

public class Cat extends Pet {
@Override
public String getName() {
return name;
}

@Override
public void setName(String name) {
this.name = name;
}

String name;
public Cat(){
super("Garfield");
}

@Override
public String speak() {
return "Meow";
}
}
66 changes: 66 additions & 0 deletions src/main/java/io/zipcoder/polymorphism/Console.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package io.zipcoder.polymorphism;

import javax.swing.plaf.IconUIResource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Console {
Scanner scanner = new Scanner(System.in);
private List<Pet> pets = new ArrayList<Pet>();
Integer numPets;

public void numberOfPets(){
System.out.println("How many pets do you own?");
Integer numPets = scanner.nextInt();
typeOfPet();
}

public void typeOfPet(){
int counter = 0;
int input;

for (int i = 0; i < pets.size(); i++) {
System.out.println("What type of pet(s) do you have?" + (counter + 1));
System.out.println("1. Dog | 2. Cat | 3. Bird");
input = scanner.nextInt();
switch (input){
case 1:
pets.add(new Dog());
break;
case 2:
pets.add(new Cat());
break;
case 3:
pets.add(new Bird());
break;

default:
System.out.println("cmon bruh do it right");
typeOfPet();
break;
}
counter++;
}
nameOfPet();

}

public void nameOfPet() {
int petIndex;
String input;
for (int i = 0; i < numPets; i++) {


}
}
}



// if(numPets <= 1){
// System.out.println("What is your pet's name?");
// }else{
// System.out.println("What are your pet's names?");
// }
24 changes: 24 additions & 0 deletions src/main/java/io/zipcoder/polymorphism/Dog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.zipcoder.polymorphism;

public class Dog extends Pet {
String name;

@Override
public String getName() {
return name;
}

@Override
public void setName(String name) {
this.name = name;
}

public Dog(){
super("Beans");
}

@Override
public String speak() {
return "Bark";
}
}
13 changes: 12 additions & 1 deletion src/main/java/io/zipcoder/polymorphism/MainApplication.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
package io.zipcoder.polymorphism;

import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class MainApplication {
}
public static void main(String[] args) {

}

}
23 changes: 23 additions & 0 deletions src/main/java/io/zipcoder/polymorphism/Pet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.zipcoder.polymorphism;

public class Pet {
String name;
public Pet(){
this.name = "Noname";
}
public Pet(String name){
this.name = name;

}
public String speak(){
return null;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}