The Artima Developer Community
Sponsored Link

Java Answers Forum
New to Java

1 reply on 1 page. Most recent reply: Nov 25, 2002 12:12 PM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Pete

Posts: 1
Nickname: deca
Registered: Nov, 2002

New to Java Posted: Nov 25, 2002 8:07 AM
Reply to this message Reply
Advertisement
I am trying to do a basic SalesPerson class. We suppose that a salesperson has a name (modelled by a String),
a basic (monthly) pay (a double), and a sales target (a double, representing the sums of the prices of all
the items she/he should aim to sell during a month).
Using BlueJ, create a assignment1 project, and within this write a SalesPerson class which contains
(i) declarations of name, basicPay and salesTarget instance fields; (ii) a constructor which
initialises these instance fields (using its three parameter values); and (iii) getName, getBasicPay and
getSalesTarget methods which return the values of the three instance fields. This is what im trying to do please could some write the class, or just get me started .thanks


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: New to Java Posted: Nov 25, 2002 12:12 PM
Reply to this message Reply
/**	SalesPerson.java
*	@author Charles Bell
*	@version Nov 25, 2002
*	SalesPerson class which contains 
*		(i) 	declarations of name, basicPay and salesTarget instance fields; 
*		(ii) 	a constructor which initialises these instance fields (using its 
*			three parameter values); and 
*		(iii) getName, getBasicPay and getSalesTarget methods which return 
*			the values of the three instance fields. 
*/
public class SalesPerson{
	
	/* declarations of name, basicPay and salesTarget instance fields */
	private String name = "";
	private double basicPay;
	private double salesTarget;
		
	/*  Constructor which initialises these instance fields 
	*	(using its three parameter values)
	*/		
	public SalesPerson(String name, double basicPay, double salesTarget){
		this.name = name;
		this.basicPay = basicPay;
		this.salesTarget = salesTarget;
	}
	
	/*	getName() method which returns the value of the name instance field.
	*/
	public String getName(){
		return name;
	}
		
	/*	getBasicPay() method which returns the value of the basicPay instance field.
	*/
	public double getBasicPay(){
		return basicPay;
	}
	
	/*	getSalesTarget() method which returns the value of the salesTarget instance field.
	*/
	public double getSalesTarget(){
		return salesTarget;
	}
 
	public void setName(String name){
		this.name = name;
	}
		
	public void setBasicPay(double basicPay){
		this.basicPay = basicPay;
	}
	
	public void setSalesTarget(double salesTarget){
		this.salesTarget = salesTarget;
	}
 
}

Flat View: This topic has 1 reply on 1 page
Topic: Arraylist catastrophe Previous Topic   Next Topic Topic: help leasse

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use