diff --git a/AvgOfThree/package.bluej b/AvgOfThree/package.bluej index 5f5f50b5..00395d8d 100644 --- a/AvgOfThree/package.bluej +++ b/AvgOfThree/package.bluej @@ -2,9 +2,9 @@ objectbench.height=100 objectbench.width=658 package.editor.height=400 -package.editor.width=560 -package.editor.x=30 -package.editor.y=30 +package.editor.width=865 +package.editor.x=860 +package.editor.y=20 package.numDependencies=0 package.numTargets=1 package.showExtends=true @@ -16,8 +16,8 @@ readme.editor.x=0 readme.editor.y=22 target1.editor.height=700 target1.editor.width=900 -target1.editor.x=70 -target1.editor.y=50 +target1.editor.x=732 +target1.editor.y=309 target1.height=50 target1.name=AvgOfThree target1.naviview.expanded=false diff --git a/Chapter 4 practice/Annuity.java b/Chapter 4 practice/Annuity.java new file mode 100644 index 00000000..296405b8 --- /dev/null +++ b/Chapter 4 practice/Annuity.java @@ -0,0 +1,39 @@ + + +/** + * Write a description of class Annuity here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class Annuity +{ + private double PMT = 10000; + private double i = .08; + private double n = 20; + /** + * Default constructor for objects of class Annuity + */ + public Annuity() + { + // initialise instance variables + int presentValue = 0 ; + } + + /** + * An example of a method - replace this comment with your own + * that describes the operation of the method + * + * @pre preconditions for the method + * (what the method assumes about the method's parameters and class's state) + * @post postconditions for the method(what the method guarantees upon completion) + * @param y description of parameter y + * @return description of the return value + */ + public void sampleMethod() + { + double presentValue = PMT * ((((Math.pow(1+i,n-1)-1)/i)/Math.pow(1+n,n-1))+1); + System.out.println(presentValue); + } + +} diff --git a/Chapter 4 practice/README.TXT b/Chapter 4 practice/README.TXT new file mode 100644 index 00000000..0de5dc9d --- /dev/null +++ b/Chapter 4 practice/README.TXT @@ -0,0 +1,13 @@ +------------------------------------------------------------------------ +This is the project README file. Here, you should describe your project. +Tell the reader (someone who does not know anything about this project) +all she needs to know. The comments should usually include at least: +------------------------------------------------------------------------ + +PROJECT TITLE: +PURPOSE OF PROJECT: +VERSION or DATE: +DEPENDENCIES: +HOW TO START THIS PROJECT: +AUTHORS: +USER INSTRUCTIONS: diff --git a/Chapter 4 practice/StringParsing.java b/Chapter 4 practice/StringParsing.java new file mode 100644 index 00000000..0321a0e0 --- /dev/null +++ b/Chapter 4 practice/StringParsing.java @@ -0,0 +1,36 @@ +import java.util.Scanner; + +/** + * Write a description of class StringParsing here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class StringParsing +{ + /** description of instance variable x (add comment for each instance variable) */ + private int x; + + /** + * Default constructor for objects of class StringParsing + */ + public StringParsing() + { + // initialise instance variables + x = 0; + } + + public void main() + { + Scanner in = new Scanner(System.in); + System.out.print("please imput a number between 1,000 and 999,999:\t"); + String rawNumber = in.next(); + int rawLength = rawNumber.length(); + int commaIndex = rawNumber.indexOf(","); + String firstHalf = rawNumber.substring(0,commaIndex); + String seccondHalf = rawNumber.substring(commaIndex+1); + String number = firstHalf + seccondHalf; + System.out.println(number); + } + +} diff --git a/Chapter 4 practice/package.bluej b/Chapter 4 practice/package.bluej new file mode 100644 index 00000000..e3f0b619 --- /dev/null +++ b/Chapter 4 practice/package.bluej @@ -0,0 +1,50 @@ +#BlueJ package file +objectbench.height=76 +objectbench.width=658 +package.editor.height=400 +package.editor.width=560 +package.editor.x=860 +package.editor.y=20 +package.numDependencies=0 +package.numTargets=3 +package.showExtends=true +package.showUses=true +project.charset=UTF-8 +target1.editor.height=1010 +target1.editor.width=840 +target1.editor.x=840 +target1.editor.y=0 +target1.height=50 +target1.name=rectangle +target1.naviview.expanded=true +target1.showInterface=false +target1.type=ClassTarget +target1.typeParameters= +target1.width=80 +target1.x=160 +target1.y=10 +target2.editor.height=700 +target2.editor.width=900 +target2.editor.x=861 +target2.editor.y=341 +target2.height=50 +target2.name=StringParsing +target2.showInterface=false +target2.type=ClassTarget +target2.typeParameters= +target2.width=100 +target2.x=70 +target2.y=70 +target3.editor.height=700 +target3.editor.width=900 +target3.editor.x=628 +target3.editor.y=508 +target3.height=50 +target3.name=Annuity +target3.naviview.expanded=true +target3.showInterface=false +target3.type=ClassTarget +target3.typeParameters= +target3.width=80 +target3.x=70 +target3.y=10 diff --git a/Chapter 4 practice/rectangle.java b/Chapter 4 practice/rectangle.java new file mode 100644 index 00000000..bf5d5de8 --- /dev/null +++ b/Chapter 4 practice/rectangle.java @@ -0,0 +1,40 @@ +import java.util.Scanner; +/** + * like a square, but not... square + * + * @author arash + * @version (a version number or a date) + */ +public class rectangle +{ + /** description of instance variable x (add comment for each instance variable) */ + private int x; + + /** + * Default constructor for objects of class rectangle + */ + public rectangle() + { + // initialise instance variables + x = 0; + } + + public void main() + { + Scanner in = new Scanner(System.in); + System.out.print("what is the lenght? \t:"); + double length = in.nextDouble(); + System.out.print("what is the width \t:"); + double width = in.nextDouble(); + double area = length*width; + double perimeter = 2*length + 2*width; + double diagonal = Math.sqrt((Math.pow(length,2)+Math.pow(width,2))); + System.out.print("\nthe area is\t:"); + System.out.println(area); + System.out.print("the perimeter is\t:"); + System.out.println(perimeter); + System.out.print("the diagonal is\t:"); + System.out.println(diagonal); + } + +} diff --git a/Chapter3Practice/Car.java b/Chapter3Practice/Car.java new file mode 100644 index 00000000..31223379 --- /dev/null +++ b/Chapter3Practice/Car.java @@ -0,0 +1,69 @@ + + +/** + * A cool hot hip young class + * tracks fuel remaining in the car as it is driven based + * on feul efficiencey + * + * @Arresh + * @version 12 september + */ +public class Car +{ + /** the fuel efficiency of this car measured in miles per gallon*/ + private double fuelEfficiency; + /**the number of gallons of fuel left in the tank*/ + private double fuelInTank; + + /** + * Default constructor for a Car of specified fuel efficiency + */ + public Car(double efficiency) + { + this.fuelEfficiency = efficiency; + this.fuelInTank = 0; + } + + /** + * Adds the specofoed number of gallons of fuel to this car's tank + * + * @pre the specified number of gallons does not excede this cars gass capacity8 + * @param gallons number of gallons of fuel to add to this car's tank + */ + public void addGas(double gallons) + { + this.fuelInTank =this.fuelInTank + gallons; + + } + + + /** + * Updates fuel in this car's tank based on the specified number of miles driven + * and this car's fuel efficiency + * + * @pre Specified number of miles does not exceed the fuel in this car's tank + * @post postconditions for the method + * (what the method guarantees upon completion) + * @param miles number of miles this car has driven + */ + public void drive(double miles) + { + double gallonsBurned = miles/ this.fuelEfficiency; + this.fuelInTank = this.fuelInTank - gallonsBurned; + + } + + /** + * returns number of gallons of fuel left in this car's tank + * + * @return's number of gallons of fuel left in this car's tank + */ + public double getGasInTank() + { + // put your code here + return this.fuelInTank; + } + + + +} diff --git a/Chapter3Practice/CarTest.java b/Chapter3Practice/CarTest.java new file mode 100644 index 00000000..8601e906 --- /dev/null +++ b/Chapter3Practice/CarTest.java @@ -0,0 +1,82 @@ + + +import static org.junit.Assert.*; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Write a description of test class CarTest here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class CarTest +{ + /** description of instance variable x (add comment for each instance variable) */ + private int x; + + /** + * Default constructor for objects of class CarTest + */ + public CarTest() + { + // initialise instance variables + x = 0; + } + + /** + * Sets up the test fixture. + * + * Called before every test case method. + */ + @Before + public void setUp() + { + } + + /** + * Tears down the test fixture. + * + * Called after every test case method. + */ + @After + public void tearDown() + { + } + + @Test + public void testGetGasInTank() + { + Car testCar = new Car(50); + double gallons = testCar.getGasInTank(); + assertEquals(0.0, gallons, 1e-6); + } + + @Test + public void testAddGas() + { + Car testCar = new Car(50); + testCar.addGas(20); + double gallons = testCar.getGasInTank(); + assertEquals(20.0, gallons, 1e-6); + + testCar.addGas(5); + gallons = testCar.getGasInTank(); + assertEquals(25.0, gallons, 1e-6); + } + + @Test + public void testDrive() + { + Car testCar = new Car(50); + testCar.addGas(20); + testCar.drive(25); + double gallons = testCar.getGasInTank(); + assertEquals(19.5, gallons, 1e-6); + + testCar.drive(100); + gallons = testCar.getGasInTank(); + assertEquals(17.5, gallons, 1e-6); + } +} \ No newline at end of file diff --git a/Chapter3Practice/Door.java b/Chapter3Practice/Door.java new file mode 100644 index 00000000..6e221fd4 --- /dev/null +++ b/Chapter3Practice/Door.java @@ -0,0 +1,64 @@ + + +/** + * not to be confused with The Doors + * + * @author (your name) + * @version (a version number or a date) + */ +public class Door +{ + /** says the name of the door */ + private String name; + private boolean state; + + /** + * Default constructor for objects of class Door + */ + public Door(boolean beggining_state, String beggining_name) + { + this.state = beggining_state; + this.name = beggining_name; + } + + /** + * An example of a method - replace this comment with your own + * that describes the operation of the method + * + * @pre preconditions for the method + * (what the method assumes about the method's parameters and class's state) + * @post postconditions for the method + * (what the method guarantees upon completion) + * @param y description of parameter y + * @return description of the return value + */ + public void close() + { + this.state = false; + } + + public void open() + { + this.state = true; + } + + public String getName() + { + return this.name; + } + public boolean getState() + { + return this.state; + } + public void setName(String newName) + { + this.name = newName; + } + + public void setState(boolean newState) + { + this.state = newState; + } + + +} diff --git a/Chapter3Practice/DoorTest.java b/Chapter3Practice/DoorTest.java new file mode 100644 index 00000000..5ebd849d --- /dev/null +++ b/Chapter3Practice/DoorTest.java @@ -0,0 +1,48 @@ + + +import static org.junit.Assert.*; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Write a description of test class DoorTest here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class DoorTest +{ + /** description of instance variable x (add comment for each instance variable) */ + private int x; + + /** + * Default constructor for objects of class DoorTest + */ + public DoorTest() + { + // initialise instance variables + x = 0; + } + + /** + * Sets up the test fixture. + * + * Called before every test case method. + */ + @Before + public void setUp() + { + } + + /** + * Tears down the test fixture. + * + * Called after every test case method. + */ + @After + public void tearDown() + { + } + +} diff --git a/Chapter3Practice/README.TXT b/Chapter3Practice/README.TXT new file mode 100644 index 00000000..0de5dc9d --- /dev/null +++ b/Chapter3Practice/README.TXT @@ -0,0 +1,13 @@ +------------------------------------------------------------------------ +This is the project README file. Here, you should describe your project. +Tell the reader (someone who does not know anything about this project) +all she needs to know. The comments should usually include at least: +------------------------------------------------------------------------ + +PROJECT TITLE: +PURPOSE OF PROJECT: +VERSION or DATE: +DEPENDENCIES: +HOW TO START THIS PROJECT: +AUTHORS: +USER INSTRUCTIONS: diff --git a/Chapter3Practice/Target.java b/Chapter3Practice/Target.java new file mode 100644 index 00000000..b6a1297f --- /dev/null +++ b/Chapter3Practice/Target.java @@ -0,0 +1,85 @@ +import java.awt.Graphics2D; +import java.awt.geom.Ellipse2D; +import java.awt.Color; +import java.util.Random; + +/** + * A target shape that can be positioned anywhere on the screen + * + * @Arresh + * @version (a version number or a date) + */ +public class Target +{ + /** description of instance variable x (add comment for each instance variable) */ + private int xLeft; + private int yTop; + private int size; + + /** + * @param x + * @param y + */ + public Target(int x, int y, int sise) + { + xLeft = x; + yTop = y; + size = sise; + } + + /** + * An example of a method - replace this comment with your own + * that describes the operation of the method + * + * @pre assumes that there exists a 10X 10 square with upper left verticie as + * inputs + * @post postconditions for the method + * (what the method guarantees upon completion) + * @param g2 The graphics context + * @return description of the return value + */ + public void draw(Graphics2D g2) + { + //the number of the ring is the radius, the smaller nestled in the larger + /*Ellipse2D.Double ring1 = new Ellipse2D.Double(xLeft+40, yTop +40, 20, 20); + Ellipse2D.Double ring2 = new Ellipse2D.Double(xLeft + 30, yTop +30, 40, 40); + Ellipse2D.Double ring3 = new Ellipse2D.Double(xLeft+20, yTop +20, 60, 60); + Ellipse2D.Double ring4 = new Ellipse2D.Double(xLeft+10, yTop+10 , 80, 80); + Ellipse2D.Double ring5 = new Ellipse2D.Double(xLeft, yTop , 100, 100); + */ + /* + Ellipse2D.Double ring1 = new Ellipse2D.Double(xLeft+40-50, yTop +40-50, 20, 20); + Ellipse2D.Double ring2 = new Ellipse2D.Double(xLeft + 30-50, yTop +30-50, 40, 40); + Ellipse2D.Double ring3 = new Ellipse2D.Double(xLeft+20-50, yTop +20-50, 60, 60); + Ellipse2D.Double ring4 = new Ellipse2D.Double(xLeft+10-50, yTop+10-50 , 80, 80); + Ellipse2D.Double ring5 = new Ellipse2D.Double(xLeft-50, yTop-50 , 100, 100); + */ + Ellipse2D.Double ring1 = new Ellipse2D.Double(xLeft- size/10, yTop - size/10, size/5, size/5); + Ellipse2D.Double ring2 = new Ellipse2D.Double(xLeft - 2*size/10, yTop -2*size/10, 2*size/5, 2*size/5); + Ellipse2D.Double ring3 = new Ellipse2D.Double(xLeft-3*size/10, yTop -3*size/10, 3*size/5, 3*size/5); + Ellipse2D.Double ring4 = new Ellipse2D.Double(xLeft-4*size/10, yTop-4*size/10 ,4*size/5,4*size/5); + Ellipse2D.Double ring5 = new Ellipse2D.Double(xLeft-size/2, yTop-size/2 , size, size); + Random Generator = new Random(); + Color random = new Color(Generator.nextInt(256),Generator.nextInt(256),Generator.nextInt(256)); + + g2.setColor(random); + g2.draw(ring5); + g2.fill(ring5); + g2.setColor(Color.WHITE); + g2.draw(ring4); + g2.fill(ring4); + g2.setColor(random); + g2.draw(ring3); + g2.fill(ring3); + g2.setColor(Color.WHITE); + g2.draw(ring2); + g2.fill(ring2); + g2.setColor(random); + g2.draw(ring1); + g2.fill(ring1); + + + + } + +} diff --git a/Chapter3Practice/TargetComponent.java b/Chapter3Practice/TargetComponent.java new file mode 100644 index 00000000..499e2159 --- /dev/null +++ b/Chapter3Practice/TargetComponent.java @@ -0,0 +1,25 @@ +import java.awt.Graphics; +import java.awt.Graphics2D; +import javax.swing.JComponent; +import java.util.Random; +/** + * Write a description of class TargetComponent here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class TargetComponent extends JComponent +{ + + public void paintComponent(Graphics g) + { + Graphics2D g2 = (Graphics2D) g; + Random Generator = new Random(); + int x = getWidth()/2; + int y = getHeight()/2; + int size = Generator.nextInt(300) + 50; + Target target1 = new Target(x,y, size); + target1.draw(g2); + } + +} diff --git a/Chapter3Practice/TargetVeiwer.java b/Chapter3Practice/TargetVeiwer.java new file mode 100644 index 00000000..ada54c15 --- /dev/null +++ b/Chapter3Practice/TargetVeiwer.java @@ -0,0 +1,28 @@ +import javax.swing.JFrame; + +/** + * Write a description of class TargetVeiwer here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class TargetVeiwer +{ + + public static void main(String[] args) + { + JFrame frame = new JFrame(); + + frame.setSize(400,400); + frame.setTitle("Get More, Pay Less"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + TargetComponent component = new TargetComponent(); + frame.add(component); + + frame.setVisible(true); + + + } + +} diff --git a/Chapter3Practice/VendingMachine.java b/Chapter3Practice/VendingMachine.java new file mode 100644 index 00000000..6ba88950 --- /dev/null +++ b/Chapter3Practice/VendingMachine.java @@ -0,0 +1,78 @@ + + +/** + * Simulates the tool of the capitalist opressors + * + * @author Arresh + * @version ¯\_(ツ)_/¯ + */ +public class VendingMachine +{ + /** description of instance variable x (add comment for each instance variable) */ + private int cans; + private int coins; + private int profit; + + /** + * Default constructor for objects of class VendingMachine + */ + public VendingMachine() + { + this.cans = 10; + this.coins = 0; + this.profit = 0; + } + + public VendingMachine(int startCans) + { + // initialise instance variables + this.cans = startCans; + this.coins = 0; + this.profit = 0; + } + + /** + * An example of a method - replace this comment with your own + * that describes the operation of the method + * + * @pre preconditions for the method + * (what the method assumes about the method's parameters and class's state) + * @post postconditions for the method + * (what the method guarantees upon completion) + * @param y description of parameter y + * @return description of the return value + */ + public int insertCoin() + { + // put your code here + this.coins += 1; + return 1; + } + + public void vendCan(int insertedCoins) + { + this.cans -= insertedCoins; + } + + public void reset(int refillCans) + { + this.profit += this.coins; + this.coins = 0; + this.cans += refillCans; + } + + public int getCans() + { + return this.cans; + } + + public int getCoins() + { + return this.coins; + } + + public int getProfit() + { + return this.profit; + } +} diff --git a/Chapter3Practice/VendingMachineTest.java b/Chapter3Practice/VendingMachineTest.java new file mode 100644 index 00000000..4973870e --- /dev/null +++ b/Chapter3Practice/VendingMachineTest.java @@ -0,0 +1,48 @@ + + +import static org.junit.Assert.*; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Write a description of test class VendingMachineTest here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class VendingMachineTest +{ + /** description of instance variable x (add comment for each instance variable) */ + private int x; + + /** + * Default constructor for objects of class VendingMachineTest + */ + public VendingMachineTest() + { + // initialise instance variables + x = 0; + } + + /** + * Sets up the test fixture. + * + * Called before every test case method. + */ + @Before + public void setUp() + { + } + + /** + * Tears down the test fixture. + * + * Called after every test case method. + */ + @After + public void tearDown() + { + } + +} diff --git a/Chapter3Practice/doc/Car.html b/Chapter3Practice/doc/Car.html new file mode 100644 index 00000000..2d7e827d --- /dev/null +++ b/Chapter3Practice/doc/Car.html @@ -0,0 +1,194 @@ + + + + + + + +Car + + + + + + + + + + + + +
+ +
+ +

+Class Car

+
+java.lang.Object
+  extended by Car
+
+
+
+
public class Car
extends java.lang.Object
+ + +

+A cool hot hip young class + tracks fuel remaining in the car as it is driven based + on feul efficiencey +

+ +

+

+
Version:
+
12 september
+
+
+ +

+ + + + + + + + + + + +
+Constructor Summary
Car(double fuelEfficiency) + +
+          Default constructor for a Car of specified fuel efficiency
+  + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidaddGas(double gallons) + +
+          Adds the specofoed number of gallons of fuel to this car's tank
+ voiddrive(double miles) + +
+          Updates fuel in this car's tank based on the specified number of miles driven + and this car's fuel efficiency
+ doublegetGasInTank() + +
+          returns number of gallons of fuel left in this car's tank
+ + + + + + + +
Methods inherited from class
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+Car

+
+public Car(double fuelEfficiency)
+
+
Default constructor for a Car of specified fuel efficiency +

+

+ + + + + + + + +
+Method Detail
+ +

+addGas

+
+public void addGas(double gallons)
+
+
Adds the specofoed number of gallons of fuel to this car's tank +

+

+
Parameters:
gallons - number of gallons of fuel to add to this car's tank
+
+
+
+ +

+drive

+
+public void drive(double miles)
+
+
Updates fuel in this car's tank based on the specified number of miles driven + and this car's fuel efficiency +

+

+
Parameters:
miles - number of miles this car has driven
+
+
+
+ +

+getGasInTank

+
+public double getGasInTank()
+
+
returns number of gallons of fuel left in this car's tank +

+

+
+
+
+ +
+ +
+ + + diff --git a/Chapter3Practice/doc/allclasses-frame.html b/Chapter3Practice/doc/allclasses-frame.html new file mode 100644 index 00000000..61e1ad96 --- /dev/null +++ b/Chapter3Practice/doc/allclasses-frame.html @@ -0,0 +1,32 @@ + + + + + + + +All Classes + + + + + + + + + + + +All Classes +
+ + + + + +
Car +
+
+ + + diff --git a/Chapter3Practice/doc/allclasses-noframe.html b/Chapter3Practice/doc/allclasses-noframe.html new file mode 100644 index 00000000..4c79ed39 --- /dev/null +++ b/Chapter3Practice/doc/allclasses-noframe.html @@ -0,0 +1,32 @@ + + + + + + + +All Classes + + + + + + + + + + + +All Classes +
+ + + + + +
Car +
+
+ + + diff --git a/Chapter3Practice/doc/constant-values.html b/Chapter3Practice/doc/constant-values.html new file mode 100644 index 00000000..7a31f44c --- /dev/null +++ b/Chapter3Practice/doc/constant-values.html @@ -0,0 +1,45 @@ + + + + + + + +Constant Field Values + + + + + + + + + + + + +
+ +
+
+

+Constant Field Values

+
+
+Contents + +
+ +
+ + + diff --git a/Chapter3Practice/doc/index.html b/Chapter3Practice/doc/index.html new file mode 100644 index 00000000..ad7f4725 --- /dev/null +++ b/Chapter3Practice/doc/index.html @@ -0,0 +1,37 @@ + + + + + + + +Generated Documentation (Untitled) + + + + + + + + +<H2> +Frame Alert</H2> + +<P> +This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. +<BR> +Link to<A HREF="Car.html">Non-frame version.</A> + + + diff --git a/Chapter3Practice/doc/logfile.txt b/Chapter3Practice/doc/logfile.txt new file mode 100644 index 00000000..b300e6a2 --- /dev/null +++ b/Chapter3Practice/doc/logfile.txt @@ -0,0 +1,47 @@ +Class documentation +<---- javadoc command: ----> +C:\PROGRA~1\Java\JDK17~1.0_6\bin\javadoc.exe +-author +-version +-nodeprecated +-package +-noindex +-notree +-nohelp +-nonavbar +-source +1.7 +-classpath +C:\Program Files\BlueJ\lib\bluejcore.jar;C:\Program Files\BlueJ\lib\junit-4.8.2.jar;\\NNHSSRV2.hs.sd203.org\aamleshi$\AP Comp Sci\unit2Classes\Chapter3Practice +-d +\\NNHSSRV2.hs.sd203.org\aamleshi$\AP Comp Sci\unit2Classes\Chapter3Practice\doc +-encoding +UTF-8 +-charset +UTF-8 +-docletpath +C:\Program Files\BlueJ\lib\bjdoclet.jar +-doclet +bluej.doclet.doclets.formats.html.HtmlDoclet +\\NNHSSRV2.hs.sd203.org\aamleshi$\AP Comp Sci\unit2Classes\Chapter3Practice\Car.java +<---- end of javadoc command ----> +Loading source file \\NNHSSRV2.hs.sd203.org\aamleshi$\AP Comp Sci\unit2Classes\Chapter3Practice\Car.java... +Constructing Javadoc information... +Standard Doclet version 1.7.0_60 +Building tree for all the packages and classes... +Generating \\NNHSSRV2.hs.sd203.org\aamleshi$\AP Comp Sci\unit2Classes\Chapter3Practice\doc\Car.html... +\\NNHSSRV2.hs.sd203.org\aamleshi$\AP Comp Sci\unit2Classes\Chapter3Practice\Car.java:11: warning - @Arresh is an unknown tag. +\\NNHSSRV2.hs.sd203.org\aamleshi$\AP Comp Sci\unit2Classes\Chapter3Practice\Car.java:31: warning - @pre is an unknown tag. +\\NNHSSRV2.hs.sd203.org\aamleshi$\AP Comp Sci\unit2Classes\Chapter3Practice\Car.java:46: warning - @pre is an unknown tag. +\\NNHSSRV2.hs.sd203.org\aamleshi$\AP Comp Sci\unit2Classes\Chapter3Practice\Car.java:46: warning - @post is an unknown tag. +\\NNHSSRV2.hs.sd203.org\aamleshi$\AP Comp Sci\unit2Classes\Chapter3Practice\Car.java:56: warning - @return's is an unknown tag. +Generating \\NNHSSRV2.hs.sd203.org\aamleshi$\AP Comp Sci\unit2Classes\Chapter3Practice\doc\package-frame.html... +Generating \\NNHSSRV2.hs.sd203.org\aamleshi$\AP Comp Sci\unit2Classes\Chapter3Practice\doc\package-summary.html... +Generating \\NNHSSRV2.hs.sd203.org\aamleshi$\AP Comp Sci\unit2Classes\Chapter3Practice\doc\constant-values.html... +Building index for all the packages and classes... +Building index for all classes... +Generating \\NNHSSRV2.hs.sd203.org\aamleshi$\AP Comp Sci\unit2Classes\Chapter3Practice\doc\allclasses-frame.html... +Generating \\NNHSSRV2.hs.sd203.org\aamleshi$\AP Comp Sci\unit2Classes\Chapter3Practice\doc\allclasses-noframe.html... +Generating \\NNHSSRV2.hs.sd203.org\aamleshi$\AP Comp Sci\unit2Classes\Chapter3Practice\doc\index.html... +Generating \\NNHSSRV2.hs.sd203.org\aamleshi$\AP Comp Sci\unit2Classes\Chapter3Practice\doc\stylesheet.css... +5 warnings diff --git a/Chapter3Practice/doc/package-frame.html b/Chapter3Practice/doc/package-frame.html new file mode 100644 index 00000000..e8b03275 --- /dev/null +++ b/Chapter3Practice/doc/package-frame.html @@ -0,0 +1,33 @@ + + + + + + + +<Unnamed> + + + + + + + + + + + +<Unnamed> + + + + +
+Classes  + +
+Car
+ + + + diff --git a/Chapter3Practice/doc/package-list b/Chapter3Practice/doc/package-list new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/Chapter3Practice/doc/package-list @@ -0,0 +1 @@ + diff --git a/Chapter3Practice/doc/package-summary.html b/Chapter3Practice/doc/package-summary.html new file mode 100644 index 00000000..f261d437 --- /dev/null +++ b/Chapter3Practice/doc/package-summary.html @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + +
+ +
+

+Package <Unnamed> +

+ + + + + + + + + +
+Class Summary
CarA cool hot hip young class + tracks fuel remaining in the car as it is driven based + on feul efficiencey
+  + +

+

+
+
+ +
+ + + diff --git a/Chapter3Practice/doc/resources/inherit.gif b/Chapter3Practice/doc/resources/inherit.gif new file mode 100644 index 00000000..c814867a Binary files /dev/null and b/Chapter3Practice/doc/resources/inherit.gif differ diff --git a/Chapter3Practice/doc/stylesheet.css b/Chapter3Practice/doc/stylesheet.css new file mode 100644 index 00000000..6ea9e516 --- /dev/null +++ b/Chapter3Practice/doc/stylesheet.css @@ -0,0 +1,29 @@ +/* Javadoc style sheet */ + +/* Define colors, fonts and other style attributes here to override the defaults */ + +/* Page background color */ +body { background-color: #FFFFFF; color:#000000 } + +/* Headings */ +h1 { font-size: 145% } + +/* Table colors */ +.TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */ +.TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */ +.TableRowColor { background: #FFFFFF; color:#000000 } /* White */ + +/* Font used in left-hand frame lists */ +.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 } +.FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } +.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } + +/* Navigation bar fonts and colors */ +.NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */ +.NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */ +.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;} +.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;} + +.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} +.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} + diff --git a/Chapter3Practice/package.bluej b/Chapter3Practice/package.bluej new file mode 100644 index 00000000..4837da96 --- /dev/null +++ b/Chapter3Practice/package.bluej @@ -0,0 +1,137 @@ +#BlueJ package file +dependency1.from=TargetComponent +dependency1.to=Target +dependency1.type=UsesDependency +dependency2.from=TargetVeiwer +dependency2.to=TargetComponent +dependency2.type=UsesDependency +objectbench.height=76 +objectbench.width=804 +package.editor.height=838 +package.editor.width=706 +package.editor.x=696 +package.editor.y=368 +package.numDependencies=2 +package.numTargets=9 +package.showExtends=true +package.showUses=true +project.charset=UTF-8 +target1.association=CarTest +target1.editor.height=1010 +target1.editor.width=840 +target1.editor.x=840 +target1.editor.y=0 +target1.height=50 +target1.name=Car +target1.naviview.expanded=true +target1.showInterface=false +target1.type=ClassTarget +target1.typeParameters= +target1.width=80 +target1.x=70 +target1.y=50 +target2.editor.height=1010 +target2.editor.width=840 +target2.editor.x=0 +target2.editor.y=0 +target2.height=50 +target2.name=DoorTest +target2.naviview.expanded=true +target2.showInterface=false +target2.type=UnitTestTargetJunit4 +target2.typeParameters= +target2.width=80 +target2.x=220 +target2.y=20 +target3.editor.height=523 +target3.editor.width=900 +target3.editor.x=688 +target3.editor.y=370 +target3.height=50 +target3.name=TargetComponent +target3.naviview.expanded=true +target3.showInterface=false +target3.type=ClassTarget +target3.typeParameters= +target3.width=130 +target3.x=140 +target3.y=210 +target4.editor.height=1010 +target4.editor.width=840 +target4.editor.x=0 +target4.editor.y=0 +target4.height=50 +target4.name=TargetVeiwer +target4.naviview.expanded=true +target4.showInterface=false +target4.type=ClassTarget +target4.typeParameters= +target4.width=100 +target4.x=190 +target4.y=120 +target5.association=DoorTest +target5.editor.height=1010 +target5.editor.width=840 +target5.editor.x=840 +target5.editor.y=0 +target5.height=50 +target5.name=Door +target5.naviview.expanded=true +target5.showInterface=false +target5.type=ClassTarget +target5.typeParameters= +target5.width=80 +target5.x=190 +target5.y=50 +target6.editor.height=598 +target6.editor.width=958 +target6.editor.x=961 +target6.editor.y=298 +target6.height=50 +target6.name=Target +target6.naviview.expanded=true +target6.showInterface=false +target6.type=ClassTarget +target6.typeParameters= +target6.width=80 +target6.x=10 +target6.y=240 +target7.editor.height=1010 +target7.editor.width=840 +target7.editor.x=0 +target7.editor.y=0 +target7.height=50 +target7.name=CarTest +target7.showInterface=false +target7.type=UnitTestTargetJunit4 +target7.typeParameters= +target7.width=80 +target7.x=100 +target7.y=20 +target8.editor.height=700 +target8.editor.width=900 +target8.editor.x=40 +target8.editor.y=20 +target8.height=50 +target8.name=VendingMachineTest +target8.naviview.expanded=true +target8.showInterface=false +target8.type=UnitTestTargetJunit4 +target8.typeParameters= +target8.width=140 +target8.x=40 +target8.y=150 +target9.association=VendingMachineTest +target9.editor.height=1010 +target9.editor.width=840 +target9.editor.x=840 +target9.editor.y=0 +target9.height=50 +target9.name=VendingMachine +target9.naviview.expanded=true +target9.showInterface=false +target9.type=ClassTarget +target9.typeParameters= +target9.width=120 +target9.x=10 +target9.y=180 diff --git a/CityscapeLab/AndrewT.java b/CityscapeLab/AndrewT.java new file mode 100644 index 00000000..3f979a61 --- /dev/null +++ b/CityscapeLab/AndrewT.java @@ -0,0 +1,27 @@ +import java.awt.*; +import javax.swing.*; +import java.io.*; +import javax.imageio.*; +import java.awt.Toolkit; +import java.awt.Graphics; +public class AndrewT extends JFrame +{ + public AndrewT() + { + //this code based on http://www.dreamincode.net/forums/topic/142056-putting-images-into-jframes/ + /*ImageIcon andrew = new ImageIcon ("andrew_arpan_heart.jpg"); + JLabel label = new JLabel (andrew); + add(label); + setSize(0,0); + setVisible(true); + add(andrew); + */ + + + } + public void draw(Graphics g) + { + Image andrew = Toolkit.getDefaultToolkit().createImage("andrew_arpan_heart2.jpg"); + g.drawImage(andrew,0,0,null); + } +} \ No newline at end of file diff --git a/CityscapeLab/Background.java b/CityscapeLab/Background.java new file mode 100644 index 00000000..677dcbfb --- /dev/null +++ b/CityscapeLab/Background.java @@ -0,0 +1,47 @@ +import java.awt.GradientPaint; +import java.awt.Color; +import java.awt.Rectangle; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.util.Random; +/** + * Creates the background for the back of the city + * + * @author (your name) + * @version (a version number or a date) + */ +public class Background +{ + // height the height of the window + // width The width of the window + private int height; + private int width; + + + /** + * Constructor for objects of class Background + */ + public Background(int pullHeight, int pullWidth) + { + // initialise instance variables + height = pullHeight; + width = pullWidth; + } + + /** + * goes through the entire frame and creates a red to blue color gradient + * @param y a sample parameter for a method + * @return the sum of x and y + */ + public void draw(Graphics2D g2) + { + // put your code here + for (float i=0; i < width; i++) + { + GradientPaint gradient = new GradientPaint(i,0,Color.BLUE,i,height,Color.RED,true); + g2.setPaint(gradient); + Rectangle backgroundSegment = new Rectangle((int)i,0,1,height); + g2.fill(backgroundSegment); + } +} +} diff --git a/CityscapeLab/Building.java b/CityscapeLab/Building.java new file mode 100644 index 00000000..6ff84ed3 --- /dev/null +++ b/CityscapeLab/Building.java @@ -0,0 +1,82 @@ +import java.util.Random; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.Color; +/** + * Creates a building object of a random height given max height + * + * @author Arresh + * @version (a version number or a date) + */ +public class Building +{ + /** description of instance variable x (add comment for each instance variable) */ + private int blockHeight; + private double height; + private double width; + private double position; + private double floor; + + /** + * Default constructor for objects of class Building + * @param startPosition Which block of 2 will the building spawn on + * @param yMax What is the maximum height + * @param xMax The max width + */ + public Building(double startPosition, double yMax, double xMax) + { + // initialise instance variables + Random generator = new Random(); + blockHeight = generator.nextInt(7)+2; + height = blockHeight*(yMax/12); + width = xMax/ 10; + position = startPosition*xMax/10; + floor = yMax; + + } + + /** + * An example of a method - replace this comment with your own + * that describes the operation of the method + * + * @post A building that fits in the set constraints + * (what the method guarantees upon completion) + * @param g2 the graphics object that will draw the building + */ + public void draw(Graphics2D g2) + { + // put your code here + Random generator = new Random(); + Color lightGray = new Color(160,160,160); + Color darkGray = new Color(42,42,42); + //Rectangle.Double base = new Rectangle.Double(position, floor, width, height); + Rectangle.Double base = new Rectangle.Double(position, floor-height, width, height); + int pickColor = generator.nextInt(2); + if (pickColor == 0) + { + g2.setColor(lightGray); + } + else + { + g2.setColor(darkGray); + } + g2.fill(base); + for (int i = 1; i