Last active
November 21, 2015 14:12
-
-
Save golenishchev/2f5953ff6be307d34ae9 to your computer and use it in GitHub Desktop.
Lesson7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Computer implements java.io.Serializable { // Creating class Computer | |
private int powerSupply; // fields | |
private float processor; | |
private int videoCard; | |
private String motherBoard; | |
public Computer() { // default constructor | |
} | |
/* getter and setter methods | |
BEGIN powerSupply */ | |
public int getPowerSupply() { | |
return powerSupply; | |
} | |
public void setPowerSupply(int powerSupply) { | |
this.powerSupply = powerSupply; | |
} | |
// BEGIN processor | |
public float getProcessor() { | |
return processor; | |
} | |
public void setProcessor(float processor) { | |
this.processor = processor; | |
} | |
// BEGIN videoCard | |
public int getVideoCard() { | |
return videoCard; | |
} | |
public void setVideoCard(int videoCard) { | |
this.videoCard = videoCard; | |
} | |
// BEGIN motherBoard | |
public String getMotherBoard() { | |
return motherBoard; | |
} | |
public void setMotherBoard(String motherBoard) { | |
this.motherBoard = motherBoard; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
Computer myComp = new Computer(); // object myComp. Without this line it wouldn't compile. | |
public static void main (String args[]) { | |
Computer myComp = new Computer(); // object myComp | |
myComp.setPowerSupply(450); | |
myComp.setProcessor(2.4f); | |
myComp.setVideoCard(11); | |
myComp.setMotherBoard("Asus P5K"); | |
System.out.println(myComp.getPowerSupply() + "\n" + myComp.getProcessor() | |
+ "\n" + myComp.getVideoCard() + "\n" + myComp.getMotherBoard()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment