|
I've read this question a few times. Each time, I come back to the idea that you are wanting to talk to a web service and what you have at your side is the XML service definition. Is this correct?
|
|
|
|
|
let me tell u in detail
i want to call XML API from OPEN WEATHER website
and then
parse it
and only obtain temperature, humidity and visibilty from there
then all to display in my application
which i have created in C# in MICROSOFT VISUAL STUDIO 2013
it can be displayed in text box , or label etc
and that application
and that i have built is WINDOWS FORM APPLICATION
modified 17-Nov-15 0:13am.
|
|
|
|
|
|
i need to write a program as per the below question
Question : Write a class named Document to represent a document node in a print queue. it should contain a method name that returns the subject of the document and an abstract method called type that returns the document type . from document class derive two concrete classes named word document and pdf document.
just tell me do i need to write the above program with link list ?
how to represent document node ?
here i wrote the code for the above program. just tell me is my code is correct or design as per the above instruction?
code as follows
public class Document
{
public string Subject { get; set; }
public abstract void type();
}
public class WordDocument : Document
{
}
public class PdfDocument : Document
{
}
if i made any mistake then please rectify me. thanks
tbhattacharjee
|
|
|
|
|
Come on now!
Two questions on exactly the same homework?
Give it a try yourself, and see how far you get! You will learn a lot better by trying it than by looking at other code...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
i need help to construct the code for below program.
here is the question
Another class named Print Queue that is implemented as a linked list of Document objects. Print Queue should have a method named Push for adding a document to the end of the list, a method named pop for removing the first document from the list , and a method named DisplayContents for listing all of the documents in the Print Queue, reporting both the Name and Type of each element Print Queue should not use any standard library classes it should be own implementation of linked list.
i coded the documents class this way
public class Document
{
public string Subject { get; set; }
public abstract void type();
}
public class WordDocument : Document
{
}
public class PdfDocument : Document
{
}
if i made any mistake then please rectify me.
but not being able to code for Print Queue class which will use link list.
see this line too -- Print Queue should have a method named Push for adding a document to the end of the list, a method named pop for removing the first document from the list
stack class has Push and Pop method. so how link list can push and pop.......need idea.
help me to construct the code for above scenario.
thanks
tbhattacharjee
|
|
|
|
|
Start by creating your PrintQueue class - add a private Head variable which is a Document. Add a Next property to your Document class which is also a Document. This allows you to create the linked list.
And add the Push and Pop methods (though I wouldn't call them that myself because "push" and "pop" have specific meanings in computing, and I'd expect a Push followed by a Pop to return the document I Pushed, not the first in the list - I'd use GetHead and AddTail instead myself).
Since this is your homework, I'll not give you the code - it's pretty simple anyway - but for Push, just traverse the list until you find a null value Next, and set your new document there.
For Pop, check if there are any items in the Head, and remove it to a temporary variable, setting the value of Head to the Next value of the Document you removed. Set the Next value of the temporary value to null, and return the temporary value.
I'd suspect that you want the Document class to be abstract as well.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
are you trying to say Document will be like node class in link list.
Document class is a abstract class then how Document class can be a node?
the below code is ok ?
do i need to at all have variable data which return object or Subject property will do the job?
public abstract class Document
{
public Document next;
public Object data;
public string Subject { get; set; }
public abstract string type();
}
tbhattacharjee
|
|
|
|
|
An abstract class can have concrete properties, fields, and methods - it just can;t be instantiated. Which means that is you have this:
public abstract class Document
{
public Document Next = null;
}
public class PdfDocument : Document
{
}
public class WordDocument : Document
{
}
The you can't do this:
Document d = new Document();
Because you can't create an instance of an abstract class.
But you can do this:
Document d = new PdfDocument();
d.Next = new WordDocument();
Because you can create instances of derived concrete classes, and assign them to variables which contain the abstract base class.
It's a bit like cars: Car is an abstract concept, while Ford Fiesta is a specific concrete type of Car, so you can buy one. If you try to go into a dealers and buy "A Car" without wanting any make or model you are going to get some very funny looks...
You probably don't want the Subject to be part of the abstract base class, unless all Document types will definitely have a Subject - and you certainly don't want the content to be party of the base class because you don't know what it is or what it needs to be stored in. (Any more than you'd put the rear passenger seats in the Car class, because that would cause problems with two seaters - which don't have any - and seven seaters - which might have two rows of rear passenger seats, or two "benches" as in an old Landrover.)
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
as you said i wrote the code. you said Start by creating your PrintQueue class - add a private Head variable which is a Document. Add a Next property to your Document class which is also a Document. This allows you to create the linked list.
so i wrote the code like
class PrintQueue
{
private Document head;
public void Push(Object data)
{
Document toAdd = new Document();
toAdd.data = data;
Document current = head;
while (current.next != null)
{
current = current.next;
}
current.next = toAdd;
}
}
public abstract class Document
{
public Document next;
public Object data;
public string Subject { get; set; }
public abstract string type();
}
public class WordDocument : Document
{
public override string type()
{
return "docx";
}
}
public class PdfDocument : Document
{
public override string type()
{
return "pdf";
}
}
this line
Document toAdd = new Document(); giving error because abstract class can not be instantiated.
i failed for this area design as you said For Pop, check if there are any items in the Head, and remove it to a temporary variable, setting the value of Head to the Next value of the Document you removed. Set the Next value of the temporary value to null, and return the temporary value.
just do not being able to write code for Pop function. please help me for pop.
looking for help to complete this code. thanks
tbhattacharjee
|
|
|
|
|
See the answer I wrote to your previous comment.
What part of Pop is difficult?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
this is my full updated code but still the code is not completed and there is error.
see the code and also read my first post and guide me how to complete the program.
class PrintQueue
{
private Document head;
private int size;
public int Count
{
get
{
return size;
}
}
public void Push(Object data)
{
Document toAdd = new Document();
toAdd.data = data;
Document current = head;
while (current.Next != null)
{
current = current.Next;
}
current.Next = toAdd;
size++;
}
public bool Pop()
{
Document tempNode = head;
Document lastNode = null;
int count = 0;
if (size > 0)
{
while (tempNode != null)
{
if (count == size - 1)
{
lastNode.Next = tempNode.Next;
return true;
}
count++;
lastNode = tempNode;
tempNode = tempNode.Next;
}
}
return false;
}
}
public abstract class Document
{
public Document Next;
public Object data;
public string Subject { get; set; }
public abstract string type();
}
public class WordDocument : Document
{
public override string type()
{
return "docx";
}
}
public class PdfDocument : Document
{
public override string type()
{
return "pdf";
}
}
for this line i will get error
Document toAdd = new Document();
but how could i use there worddoc or pdfdoc class because i do not know which one should use inside in PrintQueue class?
so tell me what is the work around and also see and tell me Pop() function is properly constructed or not ?
thanks
tbhattacharjee
|
|
|
|
|
the 2 questions i was trying to solve as follows
Question 1 : Write a class named Document to represent a document node in a print queue. it should contain a method name that returns the subject of the document and an abstract method called type that returns the document type . from document class derive two concrete classes named word document and pdf document.
Question 2 : Another class named Print Queue that is implemented as a linked list of Document objects. Print Queue should have a method named Push for adding a document to the end of the list, a method named pop for removing the first document from the list , and a method named DisplayContents for listing all of the documents in the Print Queue, reporting both the Name and Type of each element Print Queue should not use any standard library classes it should be own implementation of linked list.
here i like to post whatever at last i achieved. so please see the code and question let me know is it correct as per the 2 question pasted here.
see the latest code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PrintQueueDemo
{
class PrintQueue
{
Node head;
Node tail;
public void Push(string strType, string strName)
{
if (head == null)
{
head = new Node(strType, strName);
tail = head;
}
else
{
Node node = new Node(strType, strName);
tail.setNext(node);
tail = node;
}
}
public Node.Document Pop()
{
if (head == null)
return null;
Node.Document doc = new Node.Document(head.document.Type, head.document.Name);
head = head.nextnode;
if (head == null)
tail = null;
return doc;
}
public string DisplayContents()
{
string content = "";
Node node = head;
if (node == null)
return "PrintQueue is empty";
content = node.document.Name + ": " + node.document.Type;
while (node.nextnode != null)
{
node = node.nextnode;
content += "\r\n" + node.document.Name + ": " + node.document.Type;
}
return content;
}
public class Node
{
public Document document { get; private set; }
public Node nextnode { get; private set; }
public Node(string strType, string strName)
{
document = new Document(strType, strName);
}
public void setNext(Node node)
{
nextnode = node;
}
public class Document
{
public string Type { get; private set; }
public string Name { get; private set; }
public Document(string strType, string strName)
{
Name = strName;
Type = strType;
}
}
}
}
}
PrintQueue pq = new PrintQueue();
pq.Push("cpp", "main.cpp");
pq.Push("c#", "main.cs");
pq.Push("c", "main.c");
pq.Push("h", "myinclude.h");
Console.WriteLine(pq.DisplayContents());
Console.WriteLine("===");
PrintQueue.Node.Document doc;
doc = pq.Pop();
Console.WriteLine("{0}: {1}", doc.Name, doc.Type);
doc = pq.Pop();
Console.WriteLine("{0}: {1}", doc.Name, doc.Type);
doc = pq.Pop();
Console.WriteLine("{0}: {1}", doc.Name, doc.Type);
doc = pq.Pop();
Console.WriteLine("{0}: {1}", doc.Name, doc.Type);
Console.WriteLine("===");
Console.WriteLine(pq.DisplayContents());
Console.WriteLine("===");
pq.Push("xls", "workbook.xls");
Console.WriteLine(pq.DisplayContents());
just tell me the above code will be accepted as per 2 question which i pasted at top. thanks
tbhattacharjee
|
|
|
|
|
No.
From a personal POV, I wouldn't use a tail unless I really had to - it complicates things, and it far to easy to mess it up. I'd traverse the list (or actually use a Queue rather than a linked list anyway).
But...
Why are you returning a new node on Pop? What's wrong with the actual node? Why waste time creating a new one, when it may not be the same as the original in all respects?
Why do you have a public nextnode property and a setNext method? Dump the method and make the setter public as well.
If you are going to use XML comments (and it's a good idea) use them consistently: i.e. every public object should have a "proper" comment.
What happened to the abstract Document class?
Why does your test code not check for nulls? There is no point in returning null for an error if you don't check for it anywhere!
Why do it like this:
content = node.document.Name + ": " + node.document.Type;
while (node.nextnode != null)
{
node = node.nextnode;
content += "\r\n" + node.document.Name + ": " + node.document.Type;
} Try changing it round:
while (node.nextnode != null)
{
content += node.document.Name + ": " + node.document.Type + "\r\n";
node = node.nextnode;
} Or better, use a string builder:
public string DisplayContents()
{
StringBuilder content = new StringBuilder();
Node node = head;
while (node != null)
{
content.AppendFormat("{0} : {1}\n", node.document.Name, node.document.Type);
node = node.nextnode;
}
return content.ToString();
}
And why is Document a part of Node? Is there a good reason? I can see why you might want them to be separate classes, but...
If Node inherited from Document that would make sense, or even if Document inherited from Node - but making it an encapsulated class feels very wrong, and complicates your code.
I'd probably make Node an abstract class, and inherit an abstract Document from that, then inherit the concrete PdfDocument and WordDocument you were using previously from there.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
modified 15-Nov-15 7:57am.
|
|
|
|
|
i have posted so many question for this issue with my though and code. i have one request can you please post the full right code as per your thought and thinking and it will long time for you because already i post the full code and you just need to arrange the same code as your thinking.
would you please help me posting code as per your thinking. thanks
tbhattacharjee
|
|
|
|
|
No - this is your homework, and it may seem cruel to not do it for you, but...you need to understand this stuff because the next assignment will assume that you do and build upon it. And the best way to understand it is to do it, looking at anothers code doesn't tell you why it's like it is.
Plus, you do realize that your tutor knows this site exists and would mark your code knowing you copied it from me? That's not likely to give you a good mark!
So have a go. It's not complicated once you get your head round it, and you seem to be intelligent enough to do it easily - if you stop trying to take short cuts!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I'm doing some automated testing where I read a datarow from a spreadsheet then pull in a set of steps from and apply the data to a web page.
There is no dependency between the data row, each using its own browser instance to simulate an individual user.
From the little I've learned there are performance differences between parallel and thread based executions.
At the moment I intend to go thread based - but may I have some feedback from community based in your experience.
Ger
|
|
|
|
|
There is no easy answer.
Depending on the type processing required and the hardware resources available (i.e. CPU "cores"), parallelizing will perform better or it may not.
Building and tearing down tasks incurs overhead; overhead not incurred in "non-parallel" operations. If the load can be spread around, and all tasks can run independently then parallelizing can work for you; otherwise it may not. You need to benchmark your options and keep in mind your final configuration; don't optimize prematurely.
|
|
|
|
|
112 pages take 50 mins to complete sequentially
Ger
|
|
|
|
|
And?
I once got a payroll job that ran for 24 hours down to 20 minutes by presorting one of the input files.
No multitasking.
|
|
|
|
|
And ... I expect some experimentation is in order.
I've never operated beyond a single thread in a commercial environment before - I've never had the need, just like your experience a decent sort or index has always been sufficient.
If it works well, it should give me a simulated multi user situation.
Each discrete task opens a web page, browses to a URL (served by localhost) fills two text boxes hits two radios, clicks a button then kills the page.
Ger
|
|
|
|
|
I see; thank you.
The problem (IMO) you are faced with is that the response from each web page (i.e. site) can be different; based on the path to that site.
I would therefore say your app is "IO / Input bound".
In this case, parallel processing should help since other tasks can run while others wait for a web response (using asynchronous callbacks).
(Out of curiosity, I would put "stop watch" code around my internet accesses and time them for the various sites).
|
|
|
|
|
For the specific test threading reduced the elapsed time from 50 to 25 mins, and significantly improved CPU utilisation.
Ger
|
|
|
|
|
I'm trying to take data collected on a form, and output it to another form, but I'm getting an "inaccessible due to its protection level" error.
So I have form A, that has a panel with some dynamically generated textboxes.
FormA -> panelA -> txtQtyA
In Form B, I want to access the data, and I'm trying to use:
txtQtyB.text = FromA.panelA.txtQtyA.Text, but I get the error for panelA.
I have tried changing the forms constructor to Public, just to see if it would "see" it with no luck.
Any assistance would be appreciated.
|
|
|
|
|
You need to edit this: "FromA.panelA.txtQtyA" in the Visual Designer. It's got a property called "Modifiers" which is set to Private. You'll want to make that either Internal or Public - depending on your needs.
Best,
John
-- LogWizard Meet the Log Viewer that makes monitoring log files a joy!
|
|
|
|