diff --git a/StudentClass/Student.java b/StudentClass/Student.java new file mode 100644 index 0000000..402125e --- /dev/null +++ b/StudentClass/Student.java @@ -0,0 +1,45 @@ +/* + * + * Build Student Class + * Private fields + * *String name default to Louie + * *double gpa default to 1.0 + * + * Default constructor + * + * Public member methods + **setName() & getName() + **setGPA() & getGPA() + */ + + +/* + * Comments for submission + * + * It was certainly a bit of a refresher to go back and review + * how classes work in Java. However, no problems. Easy peasy. + * */ + +public class Student { + private String name; + private double gpa; + + public Student() { + this.name="Louie"; + this.gpa = 1.0; + } + + public void setName(String name) { + this.name = name; + } + public String getName(){ + return this.name; + } + + public void setGPA(double gpa){ + this.gpa = gpa; + } + public double getGPA(){ + return this.gpa; + } +} diff --git a/StudentClass/fuck.java b/StudentClass/fuck.java new file mode 100644 index 0000000..6339fa6 --- /dev/null +++ b/StudentClass/fuck.java @@ -0,0 +1,13 @@ +public class fuck { + public static void main(String[] args) { + Student jack = new Student(); + + System.out.println(jack.getGPA()); + jack.setGPA(2.0); + System.out.println(jack.getGPA()); + + System.out.println(jack.getName()); + jack.setName("fart"); + System.out.println(jack.getName()); + } +} diff --git a/output-below-amount/outputBelowAmount.java b/old/output-below-amount/outputBelowAmount.java similarity index 100% rename from output-below-amount/outputBelowAmount.java rename to old/output-below-amount/outputBelowAmount.java diff --git a/word-freq/wordFreq.java b/old/word-freq/wordFreq.java similarity index 100% rename from word-freq/wordFreq.java rename to old/word-freq/wordFreq.java diff --git a/productClass/Product.java b/productClass/Product.java new file mode 100644 index 0000000..ab85ec7 --- /dev/null +++ b/productClass/Product.java @@ -0,0 +1,76 @@ +/* + * + * Given main(), define the Product class that will manage + * product inventory + * + * three private member fields + * *productCode (String) + * *productPrice (double) + * *productInInventory (int) + * + * public Product(String code, double price, int count) + * ** Set the member fields using the three params + * + * public void setCode(String code) + * ** Set the product code to parameter code + * + * public String getCode() -- return product code + * + * public void setPrice(double p) - set price to parameter p + * + * public double getPrice() -- return price + * + * public void setCount(int num) + * **set the number of items in inventory to parameter num + * + * public int getCount() -- return count + * + * public void addInventory(int amt) - increase inventory by amt + * public void sellInventory(int amt) - decrease inv by amt + */ + +// Lots of stuff in this assignment on black board all run together +// somewhat hard to review and be sure I noticed everything. +// it's also not clear what +// "Given main(), define the Product class..." +// I'm reading that as, I don't have to write a main file (except to test) +// Though, it makes me think I should have some main file available to me. +// +// So, I wrote a main file for myself to do the printing for testing that +// outputs as in the example. And as instructed, I'll only upload my class code + +public class Product { + private String code; + private double price; + private int count; + + public Product (String code, double price, int count){ + this.code = code; + this.price = price; + this.count = count; + } + public void setCode(String code){ + this.code = code; + } + public String getCode(){ + return this.code; + } + public void setPrice(double price){ + this.price = price; + } + public double getPrice(){ + return this.price; + } + public void setCount(int count){ + this.count = count; + } + public int getCount(){ + return this.count; + } + public void addInventory(int amt){ + this.count += amt; + } + public void sellInventory(int amt){ + this.count -= amt; + } +} diff --git a/productClass/testProduct.java b/productClass/testProduct.java new file mode 100644 index 0000000..d2df2a8 --- /dev/null +++ b/productClass/testProduct.java @@ -0,0 +1,22 @@ +public class testProduct { + + public static void main(String[] args) { + Product jeans = new Product("jeans", 12.34, 75); + + System.out.println( + "Name: " + jeans.getCode() + + "\nPrice: " + jeans.getPrice() + + "\nCount: " + jeans.getCount()); + jeans.setCode("New Jeans"); + jeans.setPrice(10.0); + jeans.addInventory(5); + + System.out.println( + "Name: " + jeans.getCode() + + "\nPrice: " + jeans.getPrice() + + "\nCount +5 : " + jeans.getCount()); + jeans.sellInventory(20); + System.out.println( + "Count -20 : " +jeans.getCount()); + } +}