C# find cost, calculate the cost of item and include 10% GST - c#-2.0

I am studying C# and have been asked to create a grocery program. I am stuck and can't seem to find anything on the net to help me. I have created a grocery item class with properties containing Name and Price. I have also created a subclass of purchasedItem which has an integer of quantity. I now need to create a method which finds Price, calculates the Price and adds 10% GST. Any ideas of how to do this.
This is what I have so far - any help would be appreciated:
namespace Groceries1
{
class Program
{
static void Main(string[] args)
{
groceryItem mygroceryItem = new groceryItem();
mygroceryItem.play();
purchasedItem mypurchasedItem = new purchasedItem();
}
class groceryItem
{
private string myName = 0;
private int myPrice = 0;
public string Name
{
get
{
return myName;
}
set
{
myName = value;
}
}
public int Price
{
get
{
return myPrice;
}
set
{
myPrice = value;
}
}
}
class purchasedItem
{
private int myquantity = 0;
public int quantity
{
get
{
return myquantity;
}
set
{
myquantity = Price*quantity*1.1;
}
}
}
}
}

You can try this,
using System;
using System.Collections.Generic;
namespace Groceries
{
public class Program
{
public static void Main(string[] args)
{
FreshGrocery freshGrocery = new FreshGrocery();
freshGrocery.Name = "Fresh grocery";
freshGrocery.Price = 30;
freshGrocery.Weight = 0.5;
Grocery grocery = new Grocery();
grocery.Name = "Grocery";
grocery.Price = 50;
grocery.Quantity = 2;
ShoppingCart cart = new ShoppingCart();
cart.Orders = new List<GroceryItem>();
cart.Orders.Add(freshGrocery);
cart.Orders.Add(grocery);
double price = cart.Calculate();
Console.WriteLine("Price: {0}", price);
}
}
abstract class GroceryItem
{
private string name;
private double price = 0;
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
public double Price
{
get
{
return price;
}
set
{
price = value;
}
}
public abstract double Calculate();
}
class FreshGrocery: GroceryItem
{
private double weight = 0;
public double Weight
{
get
{
return weight;
}
set
{
weight = value;
}
}
public override double Calculate() {
return this.Price * this.Weight;
}
}
class Grocery: GroceryItem
{
private int quantity = 0;
private double gst = 10; // In Percentage
public int Quantity
{
get
{
return quantity;
}
set
{
quantity = value;
}
}
public override double Calculate() {
double calculatedPrice = this.Price * this.Quantity;
// VAT
if(calculatedPrice > 0)
{
calculatedPrice += calculatedPrice * (gst/100);
}
return calculatedPrice;
}
}
class ShoppingCart
{
private List<GroceryItem> orders;
public List<GroceryItem> Orders
{
get
{
return orders;
}
set
{
orders = value;
}
}
public double Calculate()
{
double price = 0;
if(this.Orders != null)
{
foreach(GroceryItem order in this.Orders)
{
price += order.Calculate();
}
}
return price;
}
}
}

Related

Cannot implicitly convert type 'Note6MVCApplication5.Models.SPGetEmpDetailsByEmpIdJoinResult' to 'Note6MVCApplication5.Models.Emp'

public ActionResult Edit(int? id)
{
Emp emp = db.SPGetEmpDetailsByEmpIdJoin(id).SingleOrDefault();
ViewData["DeptId"] = new SelectList(db.SPGetAllDeptDetails().ToList(), "DeptId", "DeptName", emp.DeptId);
return View(emp);
}
Error : Cannot implicitly convert type 'Note6MVCApplication5.Models.SPGetEmpDetailsByEmpIdJoinResult' to 'Note6MVCApplication5.Models.Emp'
Why this error is coming?
I am posting definition of SPGetEmpDetailsByEmpIdJoinResult() which is present in MVCDemoDB.Designer.cs
public partial class SPGetEmpDetailsByEmpIdJoinResult
{
private int _EmpId;
private string _EmpName;
private string _EmpJob;
private decimal _EmpSalary;
private int _DeptId;
private string _DeptName;
public SPGetEmpDetailsByEmpIdJoinResult()
{
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_EmpId", DbType="Int NOT NULL")]
public int EmpId
{
get
{
return this._EmpId;
}
set
{
if ((this._EmpId != value))
{
this._EmpId = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_EmpName", DbType="VarChar(50) NOT NULL", CanBeNull=false)]
public string EmpName
{
get
{
return this._EmpName;
}
set
{
if ((this._EmpName != value))
{
this._EmpName = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_EmpJob", DbType="VarChar(50) NOT NULL", CanBeNull=false)]
public string EmpJob
{
get
{
return this._EmpJob;
}
set
{
if ((this._EmpJob != value))
{
this._EmpJob = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_EmpSalary", DbType="Money NOT NULL")]
public decimal EmpSalary
{
get
{
return this._EmpSalary;
}
set
{
if ((this._EmpSalary != value))
{
this._EmpSalary = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_DeptId", DbType="Int NOT NULL")]
public int DeptId
{
get
{
return this._DeptId;
}
set
{
if ((this._DeptId != value))
{
this._DeptId = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_DeptName", DbType="VarChar(50) NOT NULL", CanBeNull=false)]
public string DeptName
{
get
{
return this._DeptName;
}
set
{
if ((this._DeptName != value))
{
this._DeptName = value;
}
}
}
}
It seems to be Type Cast Error. i would suggest declare variable of type 'var' instead of Emp in below statement
Emp emp = db.SPGetEmpDetailsByEmpIdJoin(id).SingleOrDefault();
to something like this
var emp = db.SPGetEmpDetailsByEmpIdJoin(id).SingleOrDefault();
second approach
Define extension method to cast SPGetEmpDetailsByEmpIdJoinResult to Emp some thing like below
sample Emp class
public class Emp
{
public int DeptId { get; set; }
public int EmpId { get; set; }
/*
* define other properties
*/
}
public static Emp ToEmp(this SPGetEmpDetailsByEmpIdJoinResult empResult)
{
return new Emp() {EmpId = empResult.EmpId, DeptId = empResult.DeptId};
}
and call the extension method
Emp emp = db.SPGetEmpDetailsByEmpIdJoin(id).SingleOrDefault().ToEmp();
that would fix your issue. hope this helps :)

Listview Filter with SearchView Using Base Adapter in Xamarin android Error

I am try to filter listview with searchview using Base Adapter in in xamarin Android, My listView Bind in sql server using restfull web service i am stuck in PublishResults which is given an error
Here Is My Code:-
GetHospNames.cs
public class GetHospNames
{
public string HospID { get; set; }
public string HospName { get; set; }
public GetHospNames(string HospID, string HospName)
{
this.HospID = HospID;
this.HospName = HospName;
//this.HospLogo = HospLogo;
}
}
ContListViewHospNameClass.cs
using System.Collections.Generic;
using Android.App;
using Android.Views;
using Android.Widget;
using System;
using Android.Graphics;
using Android.Graphics.Drawables;
using System.IO;
using Android.Content;
using Java.Lang;
using Android.Text;
using Java.Util;
using Oject = Java.Lang.Object;
namespace HSAPP
{
public class ContListViewHospNameClass : BaseAdapter<GetHospNames>, IFilterable
{
public List<GetHospNames> objList;
Activity objActivity;
List<GetHospNames> filterList;
public ContListViewHospNameClass(Activity objMyAct, List<GetHospNames> objMyList) : base()
{
this.objActivity = objMyAct;
objList = objMyList;
this.filterList = objList;
Filter = new CustomFilter(this);
}
public override GetHospNames this[int position]
{
get
{
return objList[position];
}
}
public override int Count
{
get
{
return objList.Count;
}
}
public Filter Filter { get; set; }
public override void NotifyDataSetChanged()
{
base.NotifyDataSetChanged();
}
//This is Inner Class
public class CustomFilter : Filter
{
ContListViewHospNameClass CustomAdapter;
public CustomFilter(ContListViewHospNameClass adapter) : base()
{
this.CustomAdapter = adapter;
}
protected override FilterResults PerformFiltering(ICharSequence constraint)
{
FilterResults result = new FilterResults();
if (constraint != null && constraint.Length() > 0)
{
//Contraint To Upper
List<GetHospNames> filter = new List<GetHospNames>();
foreach (GetHospNames name in CustomAdapter.objList)
{
if (name.HospName.ToUpper().Contains(constraint.ToString().ToUpper()))
{
filter.Add(name);
}
}
Oject[] Name;
Name = new Oject[filter.Count];
for (int i = 0; i < filter.Count; i++)
{
Name[i] = filter[i].HospName.ToString();
}
result.Count = filter.Count;
result.Values = Name;
}
return result;
}
protected override void PublishResults(ICharSequence constraint, Filter.FilterResults result)
{
List<GetHospNames> filteredList = new List<GetHospNames>();
for (int i = 0; i < ((Oject[])result.Values).Length; i++)
{
filteredList.Add((Oject[])result.Values[i]);//Here Is An Error *****Cannot apply indexing with [] to an expression of type 'Object'****
}
CustomAdapter.objList = filteredList;
CustomAdapter.NotifyDataSetChanged();
}
}
public override long GetItemId(int position)
{
return position;
}
public Bitmap getBitmap(byte[] getByte)
{
if (getByte.Length != 0)
{
return BitmapFactory.DecodeByteArray(getByte, 0, getByte.Length);
}
else
{
return null;
}
}
public override View GetView(int position, View convertView, ViewGroup parent)
{
var item = objList[position];
if (convertView == null)
{
convertView = objActivity.LayoutInflater.Inflate(Resource.Layout.ContListViewHospName, null);
}
convertView.FindViewById<TextView>(Resource.Id.tvHospID).Text = item.HospID;
convertView.FindViewById<TextView>(Resource.Id.tvHospName).Text = item.HospName;
return convertView;
}
}
public static class ObjectTypeHelper
{
public static T Cast<T>(this Java.Lang.Object obj) where T : class
{
var propertyInfo = obj.GetType().GetProperty("Instance");
return propertyInfo == null ? null : propertyInfo.GetValue(obj, null) as T;
}
}
}
This is my MainActivity Code
private void BindControl_BindHospCompleted(object sender, BindControl.BindHospCompletedEventArgs e)
{
jsonValue = e.Result.ToString();
try
{
if (jsonValue == null)
{
Toast.MakeText(this, "No Data For Bind", ToastLength.Long).Show();
return;
}
JArrayValue = JArray.Parse(jsonValue);
list = new List<GetHospNames>();
int count = 0;
while (count < JArrayValue.Count)
{
GetHospNames getHospName = new GetHospNames(JArrayValue[count]["HospID"].ToString(), JArrayValue[count]["HospName"].ToString());
list.Add(getHospName);
count++;
}
if (count == 0)
{
Toast.MakeText(this, "No List Of Hospitals", ToastLength.Long).Show();
}
adapter = new ContListViewHospNameClass(this, list);
listView.Adapter = adapter;
search.QueryTextChange += (s, e) =>
{
adapter.Filter.InvokeFilter(e.NewText);
};
listView.ItemClick += ListView_ItemClick;
pBar.Dismiss();
}
catch (Java.Lang.Exception ex)
{
pBar.Dismiss();
//Toast.MakeText(this, ex.ToString(), ToastLength.Long).Show();
Finish();
Intent intent = new Intent(this, typeof(ChkIntConnActivity));
StartActivity(intent);
}
}
Please Help...Thank You

MVVMCROSS Binding TimeSyncProblem

I've got a special problem with binding data to an itemsource of an mvxtablieviewsource.
I'm trying to generate a list of favorites, which are generated in the core by clicking on a different tablview.
Normally I get the databinding working like this: (Just basic structure)
controller:
var source = new MySource(TableView);
this.AddBindings(new Dictionary<object, string>
{
{source, "ItemsSource Favs"}
});
Source:
private List<FavModel> _favs;
public override IEnumerable ItemsSource
{
get { return _favs; }
set
{
_favs = (List<FavModel>)value;
ReloadTableData();
}
}
protected override UITableViewCell GetOrCreateCellFor(UITableView tableView, NSIndexPath indexPath, object item)
{
var cell = new AdFavCell();
cell.TextLabel.Text = ((FavModel)item).Display;
return cell;
}
Normally it works really great but no in this case where i generate the data by reacting on users touch, I've got this strange failure;
When I set a breakpoint in the setter of the ItemsSource, and wait for a while then it works correctly.
When I run without a breakpoint the tableview keeps empty.
I also figured out that if I insert a manually pause in the setter then it works too:
Setter with pause:
public override IEnumerable ItemsSource
{
get { return _mydata; }
set
{
_favs = (List<FavModel>)value;
ReloadTableData();
Task.Delay(1000).Wait();
}
}
I also tried to do a delaybinding, but it didn't work.
Have anyone an idea where the problem is?
Edit:
Here some additional Information:
How the Data is generated:
I've got a tableview with content and depending on a longclick on a cell, I create a popumenu where you can add your favorites.
Detecting the longclick:
protected override UITableViewCell GetOrCreateCellFor(UITableView tableView, NSIndexPath indexPath, object item)
{
MvxTableViewCell cell = null;
if (item is SoccerEventListModel)
{
cell = tableView.DequeueReusableCell(this.CellIdentifier) as SoccerEvent;
if (cell == null)
{
cell = new SoccerEvent((SoccerEventListModel)item);
cell.AddGestureRecognizer(new UILongPressGestureRecognizer((e) =>
{
if (e.State == UIGestureRecognizerState.Began)
{
var command = ItemLongClickCommand;
if (command != null)
command.Execute(item);
}
}));
return cell;
}
}
}
Binding the Longclick to the core:
EventListViewModel.EventFavViewCallbackEvent += EventListViewModel_EventFavViewCallbackEvent;
void EventListViewModel_EventFavViewCallbackEvent(EventModel e)
{
var StoreFav = new EventFavoritesView { ViewModel = new EventFavoritesViewModel { ID = e.ID } };
View.Add(StoreFav.View);
}
Depending on the ID of the cell, it creates the list of the favorites by sending a request to our server.
Update:
private long _id;
public long ID
{
get { return _id; }
set { _id = value; RaisePropertyChanged(() => ID); Update(); }
}
When the data is received a RaisePropertyChanged() should make the view to reload its content.
private List<FavModel> _favs;
public List<FavModel> Favs
{
get { return _favs; }
set { _favs = value; RaisePropertyChanged(() => Favs); }
}
ViewModel:
public class EventFavoritesViewModel : MvxViewModel
{
private readonly EventFavoritesService _eventFavoriteService;
private readonly UserFavoritesService _userFavoriteService;
private long _id;
public long ID
{
get { return _id; }
set { _id = value; RaisePropertyChanged(() => ID); Update(); }
}
private string _title;
public string Title
{
get { return _title; }
set { _title = value; RaisePropertyChanged(() => Title); }
}
private List<FavModel> _favs;
public List<FavModel> Favs
{
get { return _favs; }
set { _favs = value; RaisePropertyChanged(() => Favs); }
}
private MvxCommand<FavModel> _itemSelectedCommand;
public System.Windows.Input.ICommand ItemSelectedCommand
{
get
{
_itemSelectedCommand = _itemSelectedCommand ?? new MvxCommand<FavModel>(ToggleFav);
return _itemSelectedCommand;
}
}
public void Init(long eventID)
{
MvxTrace.Trace("We get the details", Logger.Errorlevel.Debug);
ID = eventID;
}
public EventFavoritesViewModel()
{
_eventFavoriteService = new EventFavoritesService(UpdateEventFav);
_userFavoriteService = new UserFavoritesService(UpdateUserFav);
}
private void UpdateUserFav(Fav[] favlist)
{
MvxMessenger.Publish(new UserFavUpdateMessage(this, favlist));
}
private void Update()
{
Favs = _eventFavoriteService.GetFavforEvent(ID).MapToFavs();
}
private void UpdateEventFav(Fav[] favlist)
{
Favs = favlist.MapToFavs();
}
private void ToggleFav(FavModel item)
{
MvxTrace.Trace("Got Item: " + item.Display);
item.NewSubscription = !item.NewSubscription;
}
private IMvxMessenger MvxMessenger
{
get
{
return Mvx.Resolve<IMvxMessenger>();
}
}
public void SaveFavs()
{
foreach (var fav in Favs)
{
if (fav.AlreadySubscribed != fav.NewSubscription)
{
if (fav.NewSubscription)
_userFavoriteService.PutToUserFavorites(fav.MapToFav());
else
_userFavoriteService.DeleteFromUserFavorites(fav.MapToFav());
}
}
}
}
I hope this is enough information, otherwise just tell me.:-)
Thanks for any help.

How to filter lookup values on a dialogfield in Report Dialog based on another dialogfield in AX 2012 AOT reports?

How can i implement Customized lookup in Report Dialog box.
for example i have two fields in my report dialog 1) Custgroup 2) CustAccount
if i have selected a particuler cust group in first field then second field lookup should show only customers those come under this cust groups.
//class
public class ReportRun extends ObjectRun
{
DialogField dialogcustGroup,dialogcustaccount ;
CustTable obj_CustTable ;
}
//dialog method
public Object dialog(Object _dialog)
{
DialogRunbase dialog = _dialog;
DialogGroup toFromGroup;
Args _args;
str accountnum,custGroup;
;
// _args = new Args();
// obj_dev_CustTable = _args.record();
//accountnum = obj_dev_CustTable.AccountNum;
dialogcustGroup = dialog.addFieldValue(extendedTypeStr(CustGroup),CustGroup,"");
while select obj_CustTable
where obj_CustTable.AccountNum == dialogcustGroup .value()
{
CID = obj_dev_CustTable.CID;
dialogcustaccount =dialog.addFieldValue(ExtendedTypeStr(AccountNum),accountnum,"CID");
}
return dialog;
}
Any help would be great!!!!
The best way to do it is to override the lookup() method on the specified DialogField. See the example below - it works just fine.
class CustomizedLookup extends RunBase
{
DialogRunbase dialog;
DialogField dFieldCustGroup;
DialogField dFieldCustAccount;
CustGroupId fetchedCustGroup;
CustAccount fetchedAccountNum;
}
protected Object dialog()
{
dialog = super();
FieldCustGroup = dialog.addField(extendedTypeStr(CustGroupId),"sysLabel1");
dFieldCustGroup.allowEdit(true);
dFieldCustAccount = dialog.addField(extendedTypeStr(CustAccount),"sysLabel1");
dFieldCustAccount.allowEdit(false);
return dialog;
}
public void dialogPostRun(DialogRunbase _dialog)
{
super(_dialog);
// allow to call the event methods
// of this class (e.g. Fld1_1_modified() method)
_dialog.dialogForm().formRun().controlMethodOverload(true);
_dialog.dialogForm().formRun().controlMethodOverloadObject(this);
}
private boolean Fld1_1_modified() // dFieldCustGroup
{
FormStringControl control;
boolean isFieldModified;
control = dialog.formRun().controlCallingMethod();
isFieldModified = control.modified();
if(isFieldModified)
{
fetchedCustGroup = dFieldCustGroup.value();
dFieldCustAccount.allowEdit(true);
}
return isFieldModified;
}
private void Fld2_1_lookup() //dFieldCustAccount
{
FormStringControl control = dialog.formRun().controlCallingMethod();
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(CustTable),control);
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
queryBuildDataSource = query.addDataSource(TableNum(CustTable));
queryBuildRange = queryBuildDataSource.addRange(FieldNum(CustTable, CustGroup));
queryBuildRange.value(fetchedCustGroup);
sysTableLookup.addLookupfield(fieldnum(CustTable, AccountNum));
sysTableLookup.addLookupfield(fieldnum(CustTable, CustGroup));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
public boolean getFromDialog()
{
boolean ret;
ret = super();
fetchedAccountNum = dFieldCustAccount.value();
return ret;
}
static void main(Args _e)
{
CustomizedLookup customizedLookup;
customizedLookup = new CustomizedLookup();
if (customizedLookup.prompt())
{
customizedLookup.run();
// do some actions with your data
customizedLookup.theAction();
}
}
private void theAction()
{
info(strFmt("Customer Group: %1",fetchedCustGroup));
info(strFmt("Account Number: %1",fetchedAccountNum));
}
Some more methods like pack , unpack and main method should be declared
public class CustAmountCalculation extends RunBase
{
DialogField fieldAccount;
CustAccount custAccount;
}
public Object dialog()
{
Dialog dialog;
DialogGroup groupCustomer;
dialog = super();
fieldAccount = dialog.addField(extendedTypeStr(custAccount), "CustomerAccount");
return dialog;
}
public boolean getFromDialog()
{
custAccount = fieldAccount.value();
return super();
}
public container pack()
{
return conNull();
}
public void run()
{
CustTable custTable;
CustTrans custTrans;
;
select sum(AmountMST) from custTrans where custTrans.AccountNum == custAccount;
info("You have enetered customer information");
info(strfmt("Account: %1", custAccount));
info(strFmt("Amount: %1", custTrans.AmountMST));
}
public boolean unpack(container _packedClass)
{
return true;
}
public static void main(Args _args)
{
CustAmountCalculation custAmountCalculation = new CustAmountCalculation();
if (CustAmountCalculation.prompt())
{
CustAmountCalculation.run();
}
}

Not able to plot Date values in json graph using Struts 2 jquery chart plugin 3.4.0

I am using Struts2 jquery chart plugin 3.4.0. I am getting blank chart when i use json for getting date values from the Action class.If i use simple action then same code works fine.
Here is my jsp code.
<s:url id="chartDataUrl" action="jsonChartData"/>
<sjc:chart
id="chartDate"
xaxisMode="time"
xaxisTimeformat="%m.%Y"
xaxisMin="%{minTime}"
xaxisMax="%{maxTime}"
xaxisColor="#666"
xaxisTickSize="[3, 'month']"
xaxisTickColor="#aaa"
xaxisPosition="top"
yaxisPosition="right"
yaxisTickSize="10"
cssStyle="width: 600px; height: 400px;"
>
<sjc:chartData
id="chartAjaxData1"
label="Map -Double, Double-"
href="%{chartDataUrl}" // when i remove json call then it works fine
list="dateFromMap"
reloadTopics="reloadMap"
lines="{show : true}"
/>
</sjc:chart>
struts.xml code
<action name="jsonChartData"
class="com.ebhasin.fitnessbliss.actions.GraphsAction">
<result type="json" name="success"></result>
</action>
Action class code:
public class GraphsAction extends ActionSupport {
private String currentDate;
private Map<Date, Float> dateFromMap;
HomeService homeService = new HomeService();
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
#Override
public String execute() {
System.out.println("execute");
float weight;
Date date = new Date();
Map session = ActionContext.getContext().getSession();
Integer loginId = (Integer) session.get("loginId");
if (loginId != null) {
dateFromMap = new TreeMap<Date, Float>();
List list = homeService.getWeightGraphData(loginId);
if (list.size() > 0) {
Iterator itr = list.iterator();
while (itr.hasNext()) {
UserStats userStats = (UserStats) itr.next();
weight = userStats.getWeight();
date = userStats.getCreatedDate();
//currentDate = formatter.format(date);
dateFromMap.put(date, weight);
}
} else {
// dateFromMap.put("my",2F );
}
} else {
}
return SUCCESS;
}
public String getCurrentDate() {
return currentDate;
}
public void setCurrentDate(String currentDate) {
this.currentDate = currentDate;
}
public Map<Date, Float> getDateFromMap() {
return dateFromMap;
}
public void setDateFromMap(Map<Date, Float> dateFromMap) {
this.dateFromMap = dateFromMap;
}
}
EDIT:
Please put a System.out.println("something"); on every if / else block to see exactly where are you passing;
As a note, the preferred way to get the session object is to implement SessionAware, instead of using ActionContext;
Does your JSON Action looks like this ? :
http://struts.jgeppert.com/struts2-jquery-showcase/index.action
(go to More Widgets -> Charts -> JSON Action, in the bottom right tab.
#ParentPackage(value = "showcase")
public class JsonChartData extends ActionSupport {
private static final long serialVersionUID = 6659512910595305843L;
private List<ListValue> objList;
private Map<Double, Double> doubleMap;
#Actions( {
#Action(value = "/json-chart-data", results = {
#Result(name = "success", type = "json")
})
})
public String execute()
{
objList = new ArrayList<ListValue>();
doubleMap = new TreeMap<Double, Double>();
Random generator = new Random();
for (int i = 1; i <= 24; i++)
{
doubleMap.put(Double.valueOf("" + i), generator.nextDouble() * 10.0);
}
for (int i = 1; i <= 24; i++)
{
objList.add(new ListValue("" + i, "" + generator.nextInt(30)));
}
return SUCCESS;
}
public String getJSON()
{
return execute();
}
public List<ListValue> getObjList()
{
return objList;
}
public void setObjList(List<ListValue> objList)
{
this.objList = objList;
}
public Map<Double, Double> getDoubleMap()
{
return doubleMap;
}
public void setDoubleMap(Map<Double, Double> doubleMap)
{
this.doubleMap = doubleMap;
}
}

Resources