Skip to content

Commit

Permalink
Spring 2022 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
paulnguyen committed Jan 27, 2022
1 parent a9990f3 commit 0338d68
Show file tree
Hide file tree
Showing 132 changed files with 4,142 additions and 0 deletions.
Binary file added demos/demo3/Agile Methods (Simple Diagram).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demos/demo3/Agile Methods (Simple Diagram).sdxml
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
43 changes: 43 additions & 0 deletions demos/demo3/gumball-junit-lab/ver1/GumballMachine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

public class GumballMachine
{

private int num_gumballs;
private boolean has_quarter;

public GumballMachine( int size )
{
// initialise instance variables
this.num_gumballs = size;
this.has_quarter = false;
}

public void insertQuarter(int coin)
{
if ( coin == 25 )
this.has_quarter = true ;
else
this.has_quarter = false ;
}

public void turnCrank()
{
if ( this.has_quarter )
{
if ( this.num_gumballs > 0 )
{
this.num_gumballs-- ;
this.has_quarter = false ;
System.out.println( "Thanks for your quarter. Gumball Ejected!" ) ;
}
else
{
System.out.println( "No More Gumballs! Sorry, can't return your quarter." ) ;
}
}
else
{
System.out.println( "Please insert a quarter" ) ;
}
}
}
12 changes: 12 additions & 0 deletions demos/demo3/gumball-junit-lab/ver1/README.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
------------------------------------------------------------------------
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 he/she needs to know. The comments should usually include at least:
------------------------------------------------------------------------

PROJECT TITLE:
PURPOSE OF PROJECT:
VERSION or DATE:
HOW TO START THIS PROJECT:
AUTHORS:
USER INSTRUCTIONS:
25 changes: 25 additions & 0 deletions demos/demo3/gumball-junit-lab/ver1/package.bluej
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#BlueJ package file
objectbench.height=76
objectbench.width=783
package.editor.height=508
package.editor.width=675
package.editor.x=300
package.editor.y=103
package.numDependencies=0
package.numTargets=1
package.showExtends=true
package.showUses=true
project.charset=UTF-8
target1.editor.height=850
target1.editor.width=863
target1.editor.x=579
target1.editor.y=155
target1.height=50
target1.name=GumballMachine
target1.naviview.expanded=true
target1.showInterface=false
target1.type=ClassTarget
target1.typeParameters=
target1.width=130
target1.x=90
target1.y=10
12 changes: 12 additions & 0 deletions demos/demo3/gumball-junit-lab/ver2/README.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
------------------------------------------------------------------------
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 he/she needs to know. The comments should usually include at least:
------------------------------------------------------------------------

PROJECT TITLE:
PURPOSE OF PROJECT:
VERSION or DATE:
HOW TO START THIS PROJECT:
AUTHORS:
USER INSTRUCTIONS:
Binary file added demos/demo3/gumball-junit-lab/ver2/diagrams.asta
Binary file not shown.
46 changes: 46 additions & 0 deletions demos/demo3/gumball-junit-lab/ver2/gumball/GumballMachine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package gumball;

public class GumballMachine implements IGumball
{

private int num_gumballs;
private boolean has_quarter;

public GumballMachine( int size )
{
// initialise instance variables
this.num_gumballs = size;
this.has_quarter = false;
}

public void insertQuarter()
{
this.has_quarter = true ;
}

public void turnCrank()
{
if ( this.has_quarter )
{
if ( this.num_gumballs > 0 )
{
this.num_gumballs-- ;
this.has_quarter = false ;
System.out.println( "Thanks for your quarter. Gumball Ejected!" ) ;
}
else
{
System.out.println( "No More Gumballs! Sorry, can't return your quarter." ) ;
}
}
else
{
System.out.println( "Please insert a quarter" ) ;
}
}

public boolean hasGumball()
{
return true ;
}
}
16 changes: 16 additions & 0 deletions demos/demo3/gumball-junit-lab/ver2/gumball/GumballStub.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package gumball;


/**
* Write a description of class GumballStub here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class GumballStub implements IGumball
{

public void insertQuarter() {}
public void turnCrank() {}
public boolean hasGumball() { return true; }
}
16 changes: 16 additions & 0 deletions demos/demo3/gumball-junit-lab/ver2/gumball/IGumball.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package gumball;


/**
* Write a description of interface IGumball here.
*
* @author (your name)
* @version (a version number or a date)
*/
public interface IGumball
{

public void insertQuarter() ;
public void turnCrank() ;
public boolean hasGumball() ;
}
28 changes: 28 additions & 0 deletions demos/demo3/gumball-junit-lab/ver2/gumball/Kid.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package gumball;


/**
* Write a description of class Kid here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Kid
{
private IGumball machine;

/**
* Constructor for objects of class Kid
*/
public Kid( IGumball m )
{
machine = m ;
}


public void Mommy()
{
machine.insertQuarter() ;
machine.turnCrank() ;
}
}
73 changes: 73 additions & 0 deletions demos/demo3/gumball-junit-lab/ver2/gumball/KidTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package gumball;



import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
* The test class KidTest.
*
* @author (your name)
* @version (a version number or a date)
*/
public class KidTest
{
private gumball.IGumball m;

/**
* Default constructor for test class KidTest
*/
public KidTest()
{
}

/**
* Sets up the test fixture.
*
* Called before every test case method.
*/
@Before
public void setUp()
{
//m = new gumball.GumballMachine(10);
m = new gumball.GumballStub() ;
}

/**
* Tears down the test fixture.
*
* Called after every test case method.
*/
@After
public void tearDown()
{
}

@Test
public void testHappy()
{
m.insertQuarter();
m.turnCrank();
}

@Test
public void testHappy2()
{
m.insertQuarter();
m.turnCrank();
assertEquals(true, m.hasGumball());
}

@Test
public void noQuarter()
{
m.turnCrank();
assertEquals(false, m.hasGumball());
}
}



89 changes: 89 additions & 0 deletions demos/demo3/gumball-junit-lab/ver2/gumball/package.bluej
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#BlueJ package file
dependency1.from=Kid
dependency1.to=IGumball
dependency1.type=UsesDependency
dependency2.from=KidTest
dependency2.to=GumballMachine
dependency2.type=UsesDependency
dependency3.from=KidTest
dependency3.to=IGumball
dependency3.type=UsesDependency
dependency4.from=KidTest
dependency4.to=GumballStub
dependency4.type=UsesDependency
objectbench.height=76
objectbench.width=810
package.editor.height=525
package.editor.width=702
package.editor.x=50
package.editor.y=162
package.numDependencies=4
package.numTargets=5
package.showExtends=true
package.showUses=false
target1.editor.height=700
target1.editor.width=900
target1.editor.x=325
target1.editor.y=288
target1.height=50
target1.name=IGumball
target1.naviview.expanded=true
target1.showInterface=false
target1.type=InterfaceTarget
target1.typeParameters=
target1.width=80
target1.x=260
target1.y=100
target2.editor.height=700
target2.editor.width=900
target2.editor.x=257
target2.editor.y=147
target2.height=50
target2.name=KidTest
target2.naviview.expanded=true
target2.showInterface=false
target2.type=UnitTestTargetJunit4
target2.typeParameters=
target2.width=80
target2.x=290
target2.y=230
target3.association=KidTest
target3.editor.height=700
target3.editor.width=900
target3.editor.x=199
target3.editor.y=226
target3.height=50
target3.name=Kid
target3.naviview.expanded=true
target3.showInterface=false
target3.type=ClassTarget
target3.typeParameters=
target3.width=80
target3.x=260
target3.y=260
target4.editor.height=700
target4.editor.width=900
target4.editor.x=303
target4.editor.y=275
target4.height=50
target4.name=GumballMachine
target4.naviview.expanded=true
target4.showInterface=false
target4.type=ClassTarget
target4.typeParameters=
target4.width=130
target4.x=70
target4.y=100
target5.editor.height=700
target5.editor.width=900
target5.editor.x=90
target5.editor.y=182
target5.height=50
target5.name=GumballStub
target5.naviview.expanded=true
target5.showInterface=false
target5.type=ClassTarget
target5.typeParameters=
target5.width=100
target5.x=80
target5.y=170
22 changes: 22 additions & 0 deletions demos/demo3/gumball-junit-lab/ver2/package.bluej
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#BlueJ package file
package.editor.height=400
package.editor.width=560
package.editor.x=39
package.editor.y=347
package.numDependencies=0
package.numTargets=2
package.showExtends=true
package.showUses=true
project.charset=UTF-8
target1.height=62
target1.name=state
target1.type=PackageTarget
target1.width=80
target1.x=70
target1.y=10
target2.height=62
target2.name=gumball
target2.type=PackageTarget
target2.width=80
target2.x=160
target2.y=10
Loading

0 comments on commit 0338d68

Please sign in to comment.