Code about the Senate

profileMarlitoMaan
cs162week3project.docx

This is Me (Corey)! -Corey

The Supreme Court and Congress and Senate need to be changed to:

isActive(); getActiveCount(); and then the tests need to be changed/added-to. So that means you David (Congress), Ethan (SupremeCourt), and Maan (TheSenate)! -Corey

More different types of implementation (getters/setters/privateVariables) and tests are very welcome! -Corey

Big Project #1. Work on Oct 10-17. Turn in on Oct 17 (Monday).

People working on this project: David, Kyle, Ethan, and Me (Corey).

Instructions:

1. "Decide on an object that has not yet been implemented." class TheGovernment{}

2. "Decompose the object into a number of components."

3. class TheGovernment{} class ThePresident{} /*Me (Corey)*/ class Congress{} /*David*/ class SupremeCourt{} /*Ethan*/ class VicePresident{} /*Kyle*/

4. "split the components up among the group" ^. "be sure that each of you has at least one component that is likely to communicate somehow with another component"

5. if(!ThePresident.isAlive()){ VicePresident.makeDecision(String whatever); } if(SupremeCourt.passesBill()){ ThePresident.passOrVeto(); }

6. "as a team, design some tests for each of the components"

7. // My tests ThePresident.setAlive(true); assert ThePresident.isAlive(); ThePresident.setAlive(false); assert !ThePresident.isAlive(); // Kyle's tests VicePresident.setAlive(true); assert VicePresident.isAlive(); VicePresident.setAlive(false); assert !VicePresident.isAlive(); // David's tests Congress.setAlive(true); assert Congress.isAlive(); Congress.setAlive(false); assert !Congress.isAlive(); // Ethan's tests SupremeCourt.setAlive(true); assert SupremeCourt.isAlive(); SupremeCourt.setAlive(false); assert !SupremeCourt.isAlive();

8. "implement your assigned component"

9. // Mine class ThePresident{ public ThePresident(){ isAlive = true; } private boolean isAlive; public void setAlive(boolean _b){ isAlive = _b; } public boolean isAlive(){ return this.isAlive; } } // Kyle's class VicePresident{ private String name; private boolean isAlive; private int happinessLevel; private int age; private int height; public VicePresident(String newName, int newAge, int newHeight){ name = newName; age = newAge; height = newHeight; isAlive = true; happinessLevel = 10; } public void setAlive(boolean _b){ isAlive = _b; } public boolean isAlive(){ return this.isAlive; } public void getSandwich(){ //Make an image of a sandwich appear. At the very least, //make some text appear on the GUI saying that the VP //returned with a sandwich. happinessLevel--; } public void succession(ThePresident prez){ if(!prez.isAlive()){ //prez.setName(name); prez.setAlive(true); } } public void lookImportant(){ //Do stuff happinessLevel++; } public void rubFeet(){ //Do stuff happinessLevel--; } public int age(){ return this.age; } public int height(){ return this.height; } } // David's class Congress{ public Congress(){ isAlive = true; } private boolean isAlive; public void setAlive(boolean _b){ isAlive = _b; } public boolean isAlive(){ return this.isAlive; } } // Ethan's class SupremeCourt{ public SupremeCourt(){ isAlive = true; } private boolean isAlive; public void setAlive(boolean _b){ isAlive = _b; } public boolean isAlive(){ return this.isAlive; } }

10. "Create a basic GUI showing what inputs and outputs your component could use on its own." and "test your implementation with the tests that your team came up with"

11. // For you you just replace "ThePresident" with "VicePresident" or "Congress" or "SupremeCourt" public class MyGovernment{ private final static java.awt.Font GLOBAL_FONT = new java.awt.Font(java.awt.Font.SERIF, java.awt.Font.PLAIN, 25); public static void main(String[] _args){ ThePresident prezCorey = new ThePresident(); java.awt.Dialog myWindow = new java.awt.Dialog((java.awt.Window)null, "Week3BigProject", java.awt.Dialog.ModalityType.MODELESS); myWindow.setLayout(new java.awt.FlowLayout()); String output = "Input: isAlive: " + Boolean.toString(prezCorey.isAlive()); prezCorey.setAlive(false); output += "; Setting: isAlive(false): " + Boolean.toString(prezCorey.isAlive()); final java.awt.Label lblShowObjectInformation = new java.awt.Label(output); lblShowObjectInformation.setFont(GLOBAL_FONT); java.awt.Button btnDoTests = new java.awt.Button("Do Tests"); btnDoTests.setFont(GLOBAL_FONT); btnDoTests.addActionListener( new java.awt.event.ActionListener(){ public void actionPerformed(java.awt.event.ActionEvent _event){ ThePresident.doTests(); System.out.println("tests success!"); } } ); java.awt.Button btnExit = new java.awt.Button("Exit"); btnExit.setFont(GLOBAL_FONT); btnExit.addActionListener( new java.awt.event.ActionListener(){ public void actionPerformed(java.awt.event.ActionEvent _event){ System.exit(0); } } ); myWindow.add(lblShowObjectInformation); myWindow.add(btnDoTests); myWindow.add(btnExit); myWindow.pack(); myWindow.setLocationByPlatform(true); myWindow.setVisible(true); } } //mine class ThePresident{ public ThePresident(){ isAlive = true; } private boolean isAlive; public void setAlive(boolean _b){ isAlive = _b; } public boolean isAlive(){ return this.isAlive; } //enable asserts by running: java -ea MyGovernment public static void doTests(){ ThePresident tempPrez = new ThePresident(); assert tempPrez.isAlive; assert tempPrez.isAlive(); tempPrez.setAlive(false); assert !tempPrez.isAlive; assert !tempPrez.isAlive(); tempPrez.setAlive(true); assert tempPrez.isAlive; assert tempPrez.isAlive(); } }

Below is the code with enough commented out that it compileps:

/*This is Me (Corey)! -Corey

The Supreme Court and Congress and Senate need to be changed to:

isActive(); getActiveCount(); and then the tests need to be changed/added-to. So that means you David (Congress), Ethan (SupremeCourt), and Maan (TheSenate)! -Corey

More different types of implementation (getters/setters/privateVariables) and tests are very welcome! -Corey

Big Project #1. Work on Oct 10-17. Turn in on Oct 17 (Monday).

People working on this project: David, Kyle, Ethan, and Me (Corey).

Instructions:

"Decide on an object that has not yet been implemented." class TheGovernment{}

"Decompose the object into a number of components."

class TheGovernment{}

class ThePresident{} /*Me (Corey)

class Congress{} /*David

class SupremeCourt{} /*Ethan

class VicePresident{} /*Kyle

"split the components up among the group" ^. "be sure that each of you has at least one component that is likely to communicate somehow with another component"

if(!ThePresident.isAlive()){

VicePresident.makeDecision(String whatever);

}

if(SupremeCourt.passesBill()){

ThePresident.passOrVeto();

}

"as a team, design some tests for each of the components"*/

// My tests

/*ThePresident.setAlive(true);

assert ThePresident.isAlive();

ThePresident.setAlive(false);

assert !ThePresident.isAlive();

// Kyle's tests

VicePresident.setAlive(true);

assert VicePresident.isAlive();

VicePresident.setAlive(false);

assert !VicePresident.isAlive();

// David's tests

Congress.setAlive(true);

assert Congress.isAlive();

Congress.setAlive(false);

assert !Congress.isAlive();

// Ethan's tests

SupremeCourt.setAlive(true);

assert SupremeCourt.isAlive();

SupremeCourt.setAlive(false);

assert !SupremeCourt.isAlive();

*/

//"implement your assigned component"

// Mine

class ThePresident{

public ThePresident(){

isAlive = true;

}

private boolean isAlive;

public void setAlive(boolean _b){

isAlive = _b;

}

public boolean isAlive(){

return this.isAlive;

}

}

// Kyle's

class VicePresident{ private String name; private boolean isAlive; private int happinessLevel; private int age; private int height; public VicePresident(String newName, int newAge, int newHeight){ name = newName; age = newAge; height = newHeight; isAlive = true; happinessLevel = 10; } public void setAlive(boolean _b){ isAlive = _b; } public boolean isAlive(){ return this.isAlive; } public void getSandwich(){ //Make an image of a sandwich appear. At the very least, //make some text appear on the GUI saying that the VP //returned with a sandwich. happinessLevel--; } public void succession(ThePresident prez){ if(!prez.isAlive()){ //prez.setName(name); prez.setAlive(true); } } public void lookImportant(){ //Do stuff happinessLevel++; } public void rubFeet(){ //Do stuff happinessLevel--; } public int age(){ return this.age; } public int height(){ return this.height; } }

// David's

class Congress{

public Congress(){

isAlive = true;

}

private boolean isAlive;

public void setAlive(boolean _b){

isAlive = _b;

}

public boolean isAlive(){

return this.isAlive;

}

}

// Ethan's

class SupremeCourt{

public SupremeCourt(){

isAlive = true;

}

private boolean isAlive;

public void setAlive(boolean _b){

isAlive = _b;

}

public boolean isAlive(){

return this.isAlive;

}

}

//"Create a basic GUI showing what inputs and outputs your component could use on its own." and "test your implementation with the tests that your team came up with"

// For you you just replace "ThePresident" with "VicePresident" or "Congress" or "SupremeCourt"

public class MyGovernment{

private final static java.awt.Font GLOBAL_FONT = new java.awt.Font(java.awt.Font.SERIF, java.awt.Font.PLAIN, 25);

public static void main(String[] _args){

ThePresident prezCorey = new ThePresident();

java.awt.Dialog myWindow = new java.awt.Dialog((java.awt.Window)null, "Week3BigProject", java.awt.Dialog.ModalityType.MODELESS);

myWindow.setLayout(new java.awt.FlowLayout());

String output = "Input: isAlive: " + Boolean.toString(prezCorey.isAlive());

prezCorey.setAlive(false);

output += "; Setting: isAlive(false): " + Boolean.toString(prezCorey.isAlive());

final java.awt.Label lblShowObjectInformation = new java.awt.Label(output);

lblShowObjectInformation.setFont(GLOBAL_FONT);

java.awt.Button btnDoTests = new java.awt.Button("Do Tests");

btnDoTests.setFont(GLOBAL_FONT);

btnDoTests.addActionListener(

new java.awt.event.ActionListener(){

public void actionPerformed(java.awt.event.ActionEvent _event){

//ThePresident.doTests();

System.out.println("tests success!");

}

}

);

java.awt.Button btnExit = new java.awt.Button("Exit");

btnExit.setFont(GLOBAL_FONT);

btnExit.addActionListener(

new java.awt.event.ActionListener(){

public void actionPerformed(java.awt.event.ActionEvent _event){

System.exit(0);

}

}

);

myWindow.add(lblShowObjectInformation);

myWindow.add(btnDoTests);

myWindow.add(btnExit);

myWindow.pack();

myWindow.setLocationByPlatform(true);

myWindow.setVisible(true);

}

}

//mine

/*class ThePresident{

public ThePresident(){

isAlive = true;

}

private boolean isAlive;

public void setAlive(boolean _b){

isAlive = _b;

}

public boolean isAlive(){

return this.isAlive;

}

//enable asserts by running: java -ea MyGovernment

public static void doTests(){

ThePresident tempPrez = new ThePresident();

assert tempPrez.isAlive;

assert tempPrez.isAlive();

tempPrez.setAlive(false);

assert !tempPrez.isAlive;

assert !tempPrez.isAlive();

tempPrez.setAlive(true);

assert tempPrez.isAlive;

assert tempPrez.isAlive();

}

}

*/