diff --git a/labs/lab5/Salary.class b/labs/lab5/Salary.class new file mode 100644 index 0000000..1c12fde Binary files /dev/null and b/labs/lab5/Salary.class differ diff --git a/labs/lab5/Salary.java b/labs/lab5/Salary.java new file mode 100644 index 0000000..3cc29e9 --- /dev/null +++ b/labs/lab5/Salary.java @@ -0,0 +1,36 @@ +// *************************************************************** +// Salary.java +// Computes the raise and new salary for an employee +// *************************************************************** +import java.util.Scanner; +public class Salary +{ +public static void main (String[] args) +{ +double currentSalary; // current annual salary +double rating; // performance rating +double raise = 0; // dollar amount of the raise +Scanner scan = new Scanner(System.in); +// Get the current salary and performance rating +System.out.print ("Enter the current salary: "); +currentSalary = scan.nextDouble(); +System.out.print ("Enter the performance rating: "); +rating = scan.nextDouble(); +// Compute the raise -- Use if ... else ... + +if (rating == 1) { + raise = currentSalary * 0.06; +} else if (rating == 2) { + raise = currentSalary * 0.04; +} else if (rating == 3) { + raise = currentSalary * 0.015; +} else { + System.out.println("Rating not correctly entered!"); + return; +} + +// Print the results +System.out.println ("Amount of your raise: $" + raise); +System.out.println ("Your new salary: $" + (currentSalary + raise)); +} +} \ No newline at end of file diff --git a/labs/lab7/Dog.class b/labs/lab7/Dog.class new file mode 100644 index 0000000..514e9e8 Binary files /dev/null and b/labs/lab7/Dog.class differ diff --git a/labs/lab7/Dog.java b/labs/lab7/Dog.java new file mode 100644 index 0000000..678d721 --- /dev/null +++ b/labs/lab7/Dog.java @@ -0,0 +1,33 @@ +// **************************************************************** +// Dog.java +// +// A class that holds a dog's name and can make it speak. +// +// **************************************************************** +public abstract class Dog +{ +protected String name; +// ------------------------------------------------------------ +// Constructor -- store name +// ------------------------------------------------------------ +public Dog(String name) +{ +this.name = name; +} +// ------------------------------------------------------------ +// Returns the dog's name +// ------------------------------------------------------------ +public String getName() +{ +return name; +} +// ------------------------------------------------------------ +// Returns a string with the dog's comments +// ------------------------------------------------------------ +public String speak() +{ +return "Woof"; +} + +public abstract int avgBreedWeight(); +} \ No newline at end of file diff --git a/labs/lab7/DogTest.java b/labs/lab7/DogTest.java new file mode 100644 index 0000000..f81a10c --- /dev/null +++ b/labs/lab7/DogTest.java @@ -0,0 +1,20 @@ +// **************************************************************** +// DogTest.java +// +// A simple test class that creates a Dog and makes it speak. +// +// **************************************************************** +public class DogTest +{ +public static void main(String[] args) +{ +Dog dog = new Yorkshire("Spike"); +System.out.println(dog.getName() + " says " + dog.speak()); + +Dog Ydog = new Yorkshire("NotSpike"); +System.out.println(Ydog.getName() + " says " + Ydog.speak()); + +Dog Ldog = new Labrador("NotSpike","Black"); +System.out.println(Ldog.getName() + " says " + Ldog.speak() + " and weights: " + Ldog.avgBreedWeight()); +} +} \ No newline at end of file diff --git a/labs/lab7/Labrador.class b/labs/lab7/Labrador.class new file mode 100644 index 0000000..04631ab Binary files /dev/null and b/labs/lab7/Labrador.class differ diff --git a/labs/lab7/Labrador.java b/labs/lab7/Labrador.java new file mode 100644 index 0000000..4dc0393 --- /dev/null +++ b/labs/lab7/Labrador.java @@ -0,0 +1,33 @@ +// **************************************************************** +// Labrador.java +// +// A class derived from Dog that holds information about +// a labrador retriever. Overrides Dog speak method and includes +// information about avg weight for this breed. +// +// **************************************************************** +public class Labrador extends Dog +{ +private String color; //black, yellow, or chocolate? +private int breedWeight = 75; + +public Labrador(String name, String color) +{ +super(name); +this.color = color; +} +// ------------------------------------------------------------ +// Big bark -- overrides speak method in Dog +// ------------------------------------------------------------ +public String speak() +{ +return "WOOF"; +} +// ------------------------------------------------------------ +// Returns weight +// ------------------------------------------------------------ +public int avgBreedWeight() +{ +return breedWeight; +} +} \ No newline at end of file diff --git a/labs/lab7/Yorkshire.class b/labs/lab7/Yorkshire.class new file mode 100644 index 0000000..066a430 Binary files /dev/null and b/labs/lab7/Yorkshire.class differ diff --git a/labs/lab7/Yorkshire.java b/labs/lab7/Yorkshire.java new file mode 100644 index 0000000..6e849fa --- /dev/null +++ b/labs/lab7/Yorkshire.java @@ -0,0 +1,26 @@ +// **************************************************************** +// Yorkshire.java +// +// A class derived from Dog that holds information about +// a Yorkshire terrier. Overrides Dog speak method. +// +// **************************************************************** +public class Yorkshire extends Dog +{ +private final int breedweight = 15; +public Yorkshire(String name) +{ +super(name); +} +// ------------------------------------------------------------ +// Small bark -- overrides speak method in Dog +// ------------------------------------------------------------ +public String speak() +{ +return "woof"; +} + +public int avgBreedWeight() { + return breedweight; +} +} \ No newline at end of file diff --git a/test/Cat.class b/test/Cat.class new file mode 100644 index 0000000..f1f1786 Binary files /dev/null and b/test/Cat.class differ diff --git a/test/Cat.java b/test/Cat.java new file mode 100644 index 0000000..c41aecf --- /dev/null +++ b/test/Cat.java @@ -0,0 +1,27 @@ +public class Cat { + protected String name; + protected String color; + + +public Cat (String name, String color) { + this.name = name; + this.color = color; +} + +public String getColor() { + return color; +} + +public String getName() { + return name; +} + +public void setName(String catName) { + name = catName; +} + +public String catSays() { + return "Meow"; +} + +} \ No newline at end of file diff --git a/test/CatTest.java b/test/CatTest.java new file mode 100644 index 0000000..57f18d6 --- /dev/null +++ b/test/CatTest.java @@ -0,0 +1,6 @@ +public class CatTest { + public static void main(String[] args) { + Cat orangesmall = new Orange("Turuncu"); + System.out.println(orangesmall.getColor()+" rengi ismi de: "+orangesmall.getName()+" ve kilosu: "+orangesmall.Weight()); + } +} \ No newline at end of file diff --git a/test/Orange.class b/test/Orange.class new file mode 100644 index 0000000..60e3a07 Binary files /dev/null and b/test/Orange.class differ diff --git a/test/Orange.java b/test/Orange.java new file mode 100644 index 0000000..e2c55a3 --- /dev/null +++ b/test/Orange.java @@ -0,0 +1,13 @@ +public class Orange extends Cat +{ + private int weight = 5; + + +public Orange (String name) { + super(name, "Orange"); +} + +public int Weight() { + return weight; +} +} \ No newline at end of file