Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

practical1_answer

// Computer.Java Ths is the Super class from whch laptops and Desktops will inherit the attributes of this class
public abstract class ComputerObject {
	//Here we declare all of the superclass variables that will be used by both Laptops and desktops
	//These are attributes of all computers
	private int usefulLife = 1; 
	private String stockCode = "XXXXXXXX";
	private int purchasingCost = 10000;
	private String staffNumber = "XXXXXXXX";
	private String serialNumber = "ABCDEFG";
	private String cpuType = "Multicore Parallel Threading";
	private int ramAmount = 12;
	  
	/**Default construct Need only be present and we do not need any additional constructors except the one below*/
	 protected ComputerObject() { }
	 
	/**Construct a full Computer object. We receive all of the variable information and place them in the correct private variables using our mutators*/
    /* we use mutators because validation is often done in mutators*/	
	protected ComputerObject(int usefulLife, String stockCode,int purchasingCost,String staffNumber,String serialNumber ,String cpuType, int ramAmount) { 
		setUsfulLife(usefulLife);
		setPurchasingCost(purchasingCost);
		setRamAmount(ramAmount);
		setStockCode(stockCode);
		setStaffNumber(staffNumber);
		setCpuType(cpuType);
		setSerialNumber(serialNumber);
	}
	 
	/**Getter/Accessor method for usefulLife*/ 
	public int getUsfulLife(){
		return usefulLife; 
	 }
	 

	/**Setter/Mutator method for usefulLife*/ 
	public void setUsfulLife(int usefulLife){
		this.usefulLife = usefulLife;
	 } 
	 /**Getter/Accessor method for purchasingCost*/ 
	 public int getPurchasingCost(){
		return purchasingCost; 
	 }
	 
	/**Setter/Mutator method for purchasingCost*/ 
	public void setPurchasingCost(int purchasingCost){
		this.purchasingCost = purchasingCost;
	 } 
	 
	 /**Getter/Accessor method for ramAmount*/ 
	 public int getRamAmount(){
		return ramAmount; 
	 }
	 
	/**Setter/Mutator method for ramAmount*/ 
	public void setRamAmount(int ramAmount){
		this.ramAmount = ramAmount;
	 } 
	 
	 
	 /**Getter/Accessor method for stockCode*/ 
	public String getStockCode(){
		return stockCode; 
	 }
	 
	/**Setter/Mutator method for stockCode*/ 
	public void setStockCode(String stockCode){
		this.stockCode = stockCode; 
	 } 
	 
	 
	  /**Getter/Accessor method for staffNumber*/ 
	public String getStaffNumber(){
		return staffNumber; 
	 }
	 
	/**Setter/Mutator method for staffNumber*/ 
	public void setStaffNumber(String staffNumber){
		this.staffNumber = staffNumber ;
	 } 

	 /**Getter/Accessor method for cpuType*/ 
	public String getCpuType(){
		return cpuType; 
	 }
	 
	/**Setter/Mutator method for cpuType*/ 
	public void setCpuType(String cpuType){
		this.cpuType = cpuType ;
	 } 
	 
	 
	 
	  /**Getter/Accessor method for serialNumber*/ 
	public String getSerialNumber(){
		return serialNumber; 
	 }
	 
	/**Setter/Mutator method for serialNumber*/ 
	public void setSerialNumber(String serialNumber){
		this.serialNumber = serialNumber ;
	 } 
	 
	/**Abstract method AnnualDepreciation*/ 
	//The implimentations of this method can be found in the Laptop and Desktop sub classes
	public abstract double AnnualDepreciation(); 
}
Comment

PREVIOUS NEXT
Code Example
Java :: java opp 
Java :: fragment view in XML android 
Java :: How to merge two sorted arrays? 
Java :: how to get orientation lock to portrait android stackoverflow 
Java :: pop back stack fragment android 
Java :: lcm of two large positive integers java 
Java :: java generics 
Java :: java spring set private field in test 
Java :: how to call super onbackpressed in fragment 
Java :: exit an if statement java 
Java :: java benchmark time 
Java :: linked list vs vector 
Java :: java convert url/image to drawable 
Java :: dont kill service in android studio 
Java :: using a SnackBar on androidstudio 
Java :: thread in java 
Java :: calendar check if month is 30 days 
Java :: java words from file 
Java :: intellij set target bytecode version 
Java :: how to create search function in android studio 
Java :: android list newline 
Java :: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 
Java :: take a peice from array java 
Java :: android studio find all views in layout 
Java :: Java TreeMap Example NavigableMap 
Java :: Could not resolve project :app 
Java :: enhanced for loop arraylist 
Java :: java.lang.classcastexception: java.lang.string cannot be cast to java.util.arraylist 
Java :: how to skip a line with a filewriter java 
Java :: java linked list swap elements 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =